Example #1
0
 def test_init_start_stop(self):
     """Test camera's thread init/start/stop methods."""
     camera = Camera()
     camera.start()
     time.sleep(1)
     image = bgr8_to_jpeg(camera.value)
     camera.stop()
     # Check if image changed after stopping
     assert image == bgr8_to_jpeg(camera.value)
     
         
Example #2
0
class Observer:
    def __init__(self, camera_width, camera_height):
        self.camera = Camera(width=camera_width, height=camera_height)
        self.image = None

    def start(self):
        self.camera.observe(self._callback, names='value')
        self.camera.start()

    def stop(self):
        self.camera.stop()

    def _callback(self, change):
        img = change['new']
        # Change BGR TO RGB HWC
        self.image = img[:, :, ::-1]

    def observation(self):
        while self.image is None:
            pass
        return self.image
Example #3
0
from jetbot import Camera
import cv2

camera = Camera()

camera.start()

print(camera.value.shape)

cv2.imwrite('snapshots/1.png', camera.value,
            [int(cv2.IMWRITE_JPEG_QUALITY), 95])
cv2.waitKey(0)

camera.stop()