Пример #1
0
    def test_multi_cams_multi_source(self):
        t1 = w.VideoHandlerThread(0)
        t2 = w.VideoHandlerThread(1)

        t1.start()
        t2.start()

        SubscriberWindows(window_names=['cammy', 'cammy2'],
                          video_sources=[0, 1]).loop()

        t1.join()
        t1.join()
Пример #2
0
    def test_sub_with_callback(self):
        def redden_frame_print_spam(frame, cam_id):
            frame[:, :, 0] = 0
            frame[:, :, 1] = 0
            print("Spam!")

        w.VideoHandlerThread(callbacks=[redden_frame_print_spam] + w.display_callbacks).display()
Пример #3
0
    def test_sub_with_args(self):
        video_thread = w.VideoHandlerThread(video_source=0,
                                            callbacks=w.display_callbacks,
                                            request_size=(800, 600),
                                            high_speed=False,
                                            fps_limit=8)

        video_thread.display()
Пример #4
0
    def test_handler(self):
        def test_frame_handler(frame, cam_id):
            if self.i == 200:
                w.CamCtrl.stop_cam(cam_id)
            if self.i % 100 == 0:
                print(frame.shape)
            self.i += 1

        w.VideoHandlerThread(0, [test_frame_handler],
                             request_size=(1280, 720),
                             high_speed=True,
                             fps_limit=240)
Пример #5
0
    def test_multi_cams_one_source(self):
        def cam_handler(frame, cam_id):
            SubscriberWindows.set_global_frame_dict(cam_id, frame, frame)

        t = w.VideoHandlerThread(0, [cam_handler],
                                 request_size=(1280, 720),
                                 high_speed=True,
                                 fps_limit=240)

        t.start()

        SubscriberWindows(window_names=['cammy', 'cammy2'],
                          video_sources=[str(0)]).loop()

        t.join()
Пример #6
0
    def run_camera(
            self,
            cam=0,  # type: Union[int, np.ndarray, pilImage.Image]
            fps_limit=60,
            size=(-1, -1),
            mjpeg_compression=True):
        t = wp.VideoHandlerThread(video_source=cam,
                                  callbacks=[self.display] +
                                  wp.display_callbacks,
                                  request_size=size,
                                  high_speed=mjpeg_compression,
                                  fps_limit=fps_limit)

        t.start()

        ws.SubscriberWindows(
            window_names=[str(i) for i in range(50)],
            video_sources=[cam],
        ).loop()
        if isinstance(cam, np.ndarray):
            cam = str(hash(str(cam)))
        wp.CamCtrl.stop_cam(cam)

        t.join()
Пример #7
0
        """
        npFrame = np.asarray(frame, dtype=np.float32)
        frames = zoom_tensor_to_image_list(
            self.spatial_color_2d(
                zoom.from_image(npFrame, 3, [257, 144], m.e**.5)))
        frame = frames[0]
        for f in range(1, len(frames)):
            frame = np.concatenate((frame, frames[f]), axis=1)
        return [frame]


if __name__ == '__main__':
    """MOVE TO UNIT TESTS ONCE IMPLEMENTATION IS FINISHED."""
    retina = VisionFilter()

    t = w.VideoHandlerThread(0,
                             [retina.pyramid_callback] + w.display_callbacks,
                             request_size=(1280, 720),
                             high_speed=True,
                             fps_limit=240)

    t.start()

    SubscriberWindows(window_names=["scale " + str(i)
                                    for i in range(6)] + ['1'],
                      video_sources=[0]).loop()

    w.CamCtrl.stop_cam(0)

    t.join()
Пример #8
0
 def test_sub(self):
     w.VideoHandlerThread().display()