def compared_frames_statuses(self, motion_threshold, MAD_threshold):

        holden_frames = [0] #start with the first frame
        discarded_frames = []

        i = 0
        j = 1

        while i < self._video.frames_count()-2 and j < self._video.frames_count()-1:

            #controllo il frame successivo per vedere se sono sotto la soglia
                #si lo sono, posso aggiungere il frame alla lista di quelli da non considerare
                #no non lo sono, il frame e necessario

            if i is j:
                print "CYCLE COMPARISON ERROR"

            print "\nComparing frame #%d with frame #%d" %(i, j)

            frame_1 = self._video.frames[i].grayscaled_image()
            frame_2 = self._video.frames[j].grayscaled_image()

            comp = ImageComparator(frame_1)
            vectors = comp.get_motion_vectors(frame_2, self._searcher, MAD_threshold)

            longest_vector, max_distance = ImageComparator.longest_motion_vector(vectors)

            print "Max distance found: %f" %max_distance
            print "Longest vector is: "+ str(longest_vector)

            if max_distance < motion_threshold:
                print "Frame #%d discared.. :-) " %j
                discarded_frames.append(j) #the compared frame contains only short motion vectors, so I can discard that frame
                j += 1 #the I frame is same, the frame to be compared is the j+1 so the search continue
            else:
                print "Frame #%d holden... :-(" %j
                holden_frames.append(j) #the compared frame contains a very long motion vector, so the frame will be rendered as frame I
                i = j
                j = i+1

        holden_frames.append(self._video.frames_count()-1) #keep the last frame

        return holden_frames, discarded_frames
    def _draw_motion_vectors(self):

        sze = 3
        scene = self.ui.frame2GraphicsView.scene()
        scene.clear()
        self._draw_frame(self.image_2, self.ui.frame2GraphicsView)

        pen = QPen(Qt.red, 1, Qt.SolidLine)

        for v in self.vectors:

            x = int(v["x"])
            y = int(v["y"])
            to_x = int(v["to_x"])
            to_y = int(v["to_y"])
            MAD = v["MAD"]

            klog( "(%d, %d) => (%d, %d)" % (x,y, to_x, to_y) )


            if scene:
                if MAD < self.ui.MADThresholdSpingBox.value() and (x != to_x or y != to_y):
                    scene.addLine(x,y,to_x, to_y, pen)
                    M_PI = math.pi
                    curr_x = x - to_x
                    curr_y = y - to_y
                    if curr_x != 0 or curr_y != 0:#altrimenti la linea e lunga 0!!!
                        alpha = math.atan2 (curr_y, curr_x)
                        pa_x = sze * math.cos (alpha + M_PI / 7) + to_x
                        pa_y = sze * math.sin (alpha + M_PI / 7) + to_y
                        pb_x = sze * math.cos (alpha - M_PI / 7) + to_x
                        pb_y = sze * math.sin (alpha - M_PI / 7) + to_y

                        #scene.addLine(to_x, to_y,pa_x, pa_y)
                        #scene.addLine(to_x, to_y,pb_x, pb_y)

                        polygon = QPolygonF([QPointF(to_x-sze * math.cos (alpha), to_y-sze * math.sin (alpha)),QPointF(pa_x, pa_y),QPointF(pb_x, pb_y)])
                        scene.addPolygon(polygon, pen)


        longest_vector, max_distance = ImageComparator.longest_motion_vector(self.vectors)
        print "Max motion vector distance: %f" % max_distance