Sample code for using mac camera in a program?

前端 未结 6 1227
挽巷
挽巷 2021-02-13 13:06

I\'d like to use the camera in my Macbook in a program. I\'m fairly language agnostic - C, Java, Python etc are all fine. Could anyone suggest the best place to look for documen

6条回答
  •  悲&欢浪女
    2021-02-13 13:57

    From a related question which specifically asked the solution to be pythonic, you should give a try to motmot's camiface library from Andrew Straw. It also works with firewire cameras, but it works also with the isight, which is what you are looking for.

    From the tutorial:

    import motmot.cam_iface.cam_iface_ctypes as cam_iface
    import numpy as np
    
    mode_num = 0
    device_num = 0
    num_buffers = 32
    
    cam = cam_iface.Camera(device_num,num_buffers,mode_num)
    cam.start_camera()
    frame = np.asarray(cam.grab_next_frame_blocking())
    print 'grabbed frame with shape %s'%(frame.shape,)
    

    It is used in this sample neuroscience demo

提交回复
热议问题