双目摄像头调试笔记

淘宝 买了俩双目摄像头。28块钱一个。

货还没到,通过图片搜到 产品型号是  chusei 3d webcam

 

mac 下的测试代码

brew install  libusb

pip3 install pyusb libusb1  libusb
# need pyusb and python binding for opencv
# also need libusb installed
import cv2
import usb.core
import usb.backend.libusb1

cam=cv2.VideoCapture(1)   #mac 原生为 0,如果只有一个摄像头请用0

backend = usb.backend.libusb1.get_backend(find_library=lambda x: "/usr/lib/libusb-1.0.so")   #backend,不加会报错 No backend available
dev = usb.core.find(idVendor=0x18e3, idProduct=0x5031,backend=backend)
# simulate the SET_CUR sequence
dev.ctrl_transfer(0x21,0x01,0x0800,0x0600,[0x50,0xff])
dev.ctrl_transfer(0x21,0x01,0x0f00,0x0600,[0x00,0xf6])
dev.ctrl_transfer(0x21,0x01,0x0800,0x0600,[0x25,0x00])
dev.ctrl_transfer(0x21,0x01,0x0800,0x0600,[0x5f,0xfe])
dev.ctrl_transfer(0x21,0x01,0x0f00,0x0600,[0x00,0x03])
dev.ctrl_transfer(0x21,0x01,0x0f00,0x0600,[0x00,0x02])
dev.ctrl_transfer(0x21,0x01,0x0f00,0x0600,[0x00,0x12])
dev.ctrl_transfer(0x21,0x01,0x0f00,0x0600,[0x00,0x04])
dev.ctrl_transfer(0x21,0x01,0x0800,0x0600,[0x76,0xc3])

k=0
while (k!=ord('q')):
 ret,frame=cam.read()
 frame = cv2.resize(frame,(1280,480),interpolation=cv2.INTER_CUBIC)
 cv2.imshow("cam_test",frame)

k=cv2.waitKey(18)&0xFF
 kv=k-ord('0')
 # print(kv)
 # if press 1,2,3 or 4, change the 3d camera mode
 if kv in [1,2,3,4]:
 dev.ctrl_transfer(0x21,0x01,0x0a00,0x0600,[kv,0x00])

基于如下网址:  http://www.jianshu.com/p/2ce302d588a0

《双目摄像头调试笔记》上有3条评论

发表评论

您的电子邮箱地址不会被公开。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据