예제 #1
0
 def update(self):
     info = self.data.df.loc[self.frame_no, ['x', 'y', 'r']]
     features = statistics.order.order_process(info,
                                               self.param_dict['rad_t'][0])
     self.im0 = images.crop_img(self.im0, self.data.metadata['crop'])
     self._display_img(
         images.add_colorbar(
             images.draw_circles(
                 self.im0, features[['x', 'y', 'r', 'order_mag']].values)))
 def analyse_frame(self):
     if self.tracking:
         frame = self.cap.read_next_frame()
     else:
         frame = self.cap.find_frame(self.parameters['frame'][0])
     new_frame, boundary, cropped_frame = self.ip.process(frame)
     circles = tp.locate(new_frame, 21, characterize=False)
     circles['r'] = 15
     if self.tracking:
         return circles[['x', 'y', 'r']], boundary, ['x', 'y', 'r']
     else:
         annotated_frame = images.draw_circles(cropped_frame, circles)
         return new_frame, annotated_frame
예제 #3
0
def tracking(filename):
    core_name = os.path.splitext(filename)[0]
    vid_name = core_name + '.MP4'
    data_name = core_name + '.hdf5'
    out_name = core_name + '_check.png'
    data = dataframes.DataStore(data_name)
    crop = data.metadata['crop']
    vid = video.ReadVideo(vid_name)
    print(vid_name)
    frames = np.arange(4)*vid.num_frames//4
    ims = [images.crop_img(vid.find_frame(f), crop) for f in frames]
    circles = [data.get_info(f, ['x', 'y', 'r']) for f in frames]
    new_ims = [images.draw_circles(im, c) for im, c in zip(ims, circles)]
    out = images.vstack(images.hstack(new_ims[0], new_ims[1]),
                        images.hstack(new_ims[2], new_ims[3]))
    images.save(out, out_name)
예제 #4
0
def order(filename):
    core_name = os.path.splitext(filename)[0]
    vid_name = filename
    data_name = core_name + '.hdf5'
    out_name = core_name + '_check_order.png'
    data = dataframes.DataStore(data_name)
    crop = data.metadata['crop']
    vid = video.ReadVideo(vid_name)
    frame = 100
    im = images.crop_img(vid.find_frame(frame), crop)
    circles = data.df.loc[frame, ['x', 'y', 'r', 'order_r', 'order_i']]
    circles['order_mag'] = np.abs(circles.order_r + 1j * circles.order_i)
    circles = circles[['x', 'y', 'r', 'order_mag']].values
    out = images.draw_circles(im, circles)
    out = images.add_colorbar(out)
    images.display(out)
    images.save(out, out_name)
예제 #5
0
 def analyse_frame(self):
     if self.tracking:
         frame = self.cap.read_next_frame()
     else:
         frame = self.cap.find_frame(self.parameters['frame'][0])
     new_frame, boundary, cropped_frame = self.ip.process(frame)
     circles = images.find_circles(new_frame,
                                   self.parameters['min_dist'][0],
                                   self.parameters['p_1'][0],
                                   self.parameters['p_2'][0],
                                   self.parameters['min_rad'][0],
                                   self.parameters['max_rad'][0])
     circles = get_points_inside_boundary(circles, boundary)
     circles = check_circles_bg_color(circles, new_frame, 150)
     if self.tracking:
         return circles, boundary, ['x', 'y', 'r']
     else:
         annotated_frame = images.draw_circles(cropped_frame, circles)
         return new_frame, annotated_frame
    def analyse_frame(self):
        """
        Change steps in this method.

        This is done every frame

        Returns
        -------
        info:
            (N, X) array containing X values for N tracked objects
        boundary:
            from preprocessor
        info_headings:
            List of X strings describing the values in circles

        """
        if self.tracking:
            frame = self.cap.read_next_frame()
        else:
            frame = self.cap.find_frame(self.parameters['frame'][0])
        new_frame, boundary, cropped_frame = self.ip.process(frame)

        ### ONLY EDIT BETWEEN THESE COMMENTS
        info =tp.locate(
            new_frame,
            self.parameters['min_dist'][0],
            self.parameters['p_1'][0],
            self.parameters['p_2'][0],
            self.parameters['min_rad'][0],
            self.parameters['max_rad'][0])

        info_headings = ['x', 'y', 'r']
        ### ONLY EDIT BETWEEN THESE COMMENTS
        if self.tracking:
            return info, boundary, info_headings
        else:
            # THIS NEXT LINE CAN BE EDITED TOO
            annotated_frame = images.draw_circles(cropped_frame, info)
            return new_frame, annotated_frame