[英]how to get video from a "USB3 Vision" device?
I am trying to get a camera feed from this microscope device through Python Tkinter.我正在尝试通过 Python Tkinter 从这个显微镜设备获取摄像头信号。
I have tried using cv2 VideoCapture function, but it did not show the image.我试过使用 cv2 VideoCapture function,但它没有显示图像。
class RunningStatusFrame(ttk.Frame):
def __init__(self, parent):
ttk.Frame.__init__(self, parent)
self.parent = parent
################## Camera Feed ##################
self.camera_frame = LabelFrame(self, text="Camera Feed",
width=800, height=600)
self.camera_frame.grid(row=0, column=0, columnspan=2)
self.camera_feed = Label(self.camera_frame)
self.camera_feed.pack(fill=BOTH)
self.progress = IntVar(self)
self.cam = cv2.VideoCapture(0)
self.showFrame()
################## Progress Bar #################
self.progress_bar = ttk.Progressbar(self,
orient=HORIZONTAL,
length=150,
maximum=100,
mode='determinate',
variable=self.progress)
self.progress_bar.grid(row=1, column=0, columnspan=2)
################## Laser Status ##################
Label(self, text=" Laser:").grid(row=2, column=0, sticky=E)
self.laser_status = Label(self, text="ON", fg="#f00")
self.laser_status.grid(row=2, column=1, sticky=W)
self.updateInfo()
def updateInfo(self):
'''
Function to update information.
'''
if self.parent.parent.select() == ".!notebook.!autorunframe":
pass
self.after(300, self.updateInfo)
def showFrame(self):
'''
Update camera feed.
'''
frame = self.cam.read()
if frame[0] == False:
return None
frame = imutils.resize(frame[1], width=400)
cv2image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
img = Image.fromarray(cv2image)
imgtk = ImageTk.PhotoImage(image=img)
self.camera_feed.imgtk = imgtk
self.camera_feed.configure(image=imgtk)
self.camera_feed.after(20, self.showFrame)
def setProgress(self, value):
'''
Changes progress bar status.
'''
self.progress.set(value)
This works for the webcam from my laptop, but somehow (perhaps because my microscope is an imaging device) it does not show anything.这适用于我笔记本电脑的网络摄像头,但不知何故(可能因为我的显微镜是成像设备)它没有显示任何东西。 Anyone have done something like this?有人做过这样的事吗? Any advice would be appreciated!任何意见,将不胜感激!
Thank you谢谢
You have a "USB3 Vision" device.您有一个“USB3 Vision”设备。
"USB3 Vision" is a specific industry standard, but not part of the USB standard. “USB3 Vision”是一个特定的行业标准,但不是 USB 标准的一部分。
USB3 Vision is not a webcam . USB3 Vision不是网络摄像头。 USB webcams are Unified Video Class (UVC), a device class specified in the standard. USB 网络摄像头是统一视频 Class (UVC),标准中指定的设备 class。
Windows certainly doesn't come with a driver for USB3 Vision. Windows 当然没有 USB3 Vision 的驱动程序。 It only comes with UVC.它仅随 UVC 一起提供。
You're gonna need to talk to the manufacturer and get a driver for your video device.您需要与制造商联系并为您的视频设备获取驱动程序。 And then that driver still might not present as a video device in Windows media APIs, but you might have to talk to the driver directly.然后该驱动程序可能仍然不会在 Windows 媒体 API 中作为视频设备出现,但您可能必须直接与驱动程序对话。
You could try VideoCapture with the cv.CAP_XIMEA
flag... but I've never tried that.您可以使用cv.CAP_XIMEA
标志尝试 VideoCapture ...但我从未尝试过。 XIMEA makes devices that do USB3 Vision. XIMEA 制造支持 USB3 Vision 的设备。 If you're lucky, the OpenCV videoio
backend for XIMEA might work for your device too.如果幸运的话,XIMEA 的 OpenCV videoio
后端可能也适用于您的设备。
And definitely check out the comment above by Micka.一定要看看 Micka 上面的评论。 He strikes me as knowledgeable about these devices.他给我的印象是对这些设备了如指掌。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.