def _run(self, keep=True): print fc2.get_library_version() c = fc2.Context() if (c.get_num_of_cameras() < 1): return c.connect(*c.get_camera_from_index(0)) m, f = c.get_video_mode_and_frame_rate() print(c.get_format7_configuration()) c.start_capture() im = fc2.Image() while True: c.retrieve_buffer(im) a = np.array(im) a = cv2.resize(a, (640, 480)) a = cv2.flip(a, 0) if self.ctrl: self.ctrl.lock.acquire() self.ctrl.imageQueue.append(a) self.ctrl.haveImage = True self.ctrl.lock.release() self.ctrl.event() #cv2.imshow('rgb1', a) #cv2.waitKey(1) else: cv2.imshow('rgb', a) if not keep: key = cv2.waitKey() break else: key = cv2.waitKey(1) if key & 0xFF == ord('q'): break c.stop_capture() c.disconnect()
def test(): print fc2.get_library_version() c = fc2.Context() print c.get_num_of_cameras() c.connect(*c.get_camera_from_index(0)) print c.get_camera_info() # c.set_video_mode_and_frame_rate(fc2.VIDEOMODE_FORMAT7, # fc2.FRAMERATE_FORMAT7) #m, f = c.get_video_mode_and_frame_rate() #print m, f #print c.get_video_mode_and_frame_rate_info(m, f) print "Frame Rate:" print c.get_property_info(fc2.FRAME_RATE) p = c.get_property(fc2.FRAME_RATE) print p c.set_property(**p) c.start_capture() im = fc2.Image() [np.array(c.retrieve_buffer(im)).sum() for i in range(80)] a = np.array(im) print a.shape, a.base print a.dtype cv2.imshow('', a) cv2.waitKey() cv2.destroyAllWindows() c.stop_capture() c.disconnect()
def test(): print fc2.get_library_version() c = fc2.Context() print c.get_num_of_cameras() c.connect(*c.get_camera_from_index(0)) print c.get_camera_info() #c.set_video_mode_and_frame_rate(fc2.VIDEOMODE_1280x960Y16, #fc2.FRAMERATE_7_5) m, f = c.get_video_mode_and_frame_rate() print m, f print c.get_video_mode_and_frame_rate_info(m, f) print c.get_property_info(fc2.FRAME_RATE) p = c.get_property(fc2.FRAME_RATE) print p c.set_property(**p) c.start_capture() im = fc2.Image() print [np.array(c.retrieve_buffer(im)).sum() for i in range(80)]
def test(): print fc2.get_library_version() c = fc2.Context() print c.get_num_of_cameras() c.connect(*c.get_camera_from_index(0)) print c.get_camera_info() c.set_video_mode_and_frame_rate(fc2.VIDEOMODE_1280x960Y16, fc2.FRAMERATE_7_5) m, f = c.get_video_mode_and_frame_rate() print m, f print c.get_video_mode_and_frame_rate_info(m, f) print c.get_property_info(fc2.FRAME_RATE) p = c.get_property(fc2.FRAME_RATE) print p c.set_property(**p) c.start_capture() im = fc2.Image() print [np.array(c.retrieve_buffer(im)).sum() for i in range(80)] a = np.array(im) print a.shape, a.base c.stop_capture() c.disconnect()
def cameraSettings(self): print(fc2.get_library_version()) self.c = fc2.Context() numberCam = self.c.get_num_of_cameras() print(numberCam) self.c.connect(*self.c.get_camera_from_index(0)) print(self.c.get_camera_info()) m, f = self.c.get_video_mode_and_frame_rate() print(m, f) print(self.c.get_property_info(fc2.FRAME_RATE)) p = self.c.get_property(fc2.FRAME_RATE) print(p) self.c.set_property(**p) self.c.start_capture()
def __init__(self): """Setup the communications with the flycapture2 device.""" import flycapture2 as fc2 # FlyCapture Info printing and setup: print "\n\nlibrary version: {}\n".format(fc2.get_library_version()) self.context = fc2.Context() print "Number of Cameras: {}\n".format( self.context.get_num_of_cameras()) self.context.connect(*self.context.get_camera_from_index(0)) print "Camera Info: {}\n".format(self.context.get_camera_info()) m, f = self.context.get_video_mode_and_frame_rate() print "Video Mode: {}\nFrame Rate:{}\n".format(m, f) print "Frame Rate Property Info: {}\n".format( self.context.get_property_info(fc2.FRAME_RATE)) p = self.context.get_property(fc2.FRAME_RATE) print "Frame Rate Property: {}\n".format(p) self.context.set_property(**p) self.context.start_capture() self.fc2_image = fc2.Image() print "done with flycap2 setup" self.cam_on = True self.image = None cv2.namedWindow('raw', cv2.WINDOW_NORMAL) cv2.waitKey(5) self.__acquisition_thread = None self.lock = threading.Lock() self.run = True self.__acquisition_thread = threading.Thread(group=None, target=self.acquire, name='acquisition_thread', args=(), kwargs={}) self.__acquisition_thread.start()
cv2.waitKey(1) def produce(consumer): """Produces a set of values and forwards them to the pre-defined consumer function""" while True: data = get_data() #print('Produced {}'.format(data)) consumer.send(data) yield if __name__ == '__main__': print fc2.get_library_version() c = fc2.Context() print c.get_num_of_cameras() c.connect(*c.get_camera_from_index(0)) print c.get_camera_info() # c.set_video_mode_and_frame_rate(fc2.VIDEOMODE_1280x960Y16, # fc2.FRAMERATE_7_5) m, f = c.get_video_mode_and_frame_rate() print m, f # print c.get_video_mode_and_frame_rate_info(m, f) print c.get_property_info(fc2.FRAME_RATE) p = c.get_property(fc2.FRAME_RATE) print p c.set_property(**p) c.start_capture()