使用CentOS 7.1和OpenCV无法获得相机框架

时间:2016-12-04 03:38:36

标签: python opencv centos7

我正在使用OpenCV和CentOS,我正在使用Python测试OpenCV模块,我的相机是IPEVO P2V,代码:

import numpy as np
import cv2

a = 0
for i in range(-2000, 2000):
    t = cv2.VideoCapture(i)
    ret, t1 = t.read()
    if(ret==True):
        a = i
        break
print(a)
cap = cv2.VideoCapture(a)
count = 1
while (True):
    # Capture frame-by-frame
    ret, frame = cap.read()

# Our operations on the frame come here

# Display the resulting frame
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('c'):
    file = "/home/cro/test%d.png" % (count)
    cv2.imwrite(file,frame)
    count = count + 1
if cv2.waitKey(1) & 0xFF == ord('q'):
    break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

但出现错误:

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow,        file /home/cro/opencv-3.0.0/modules/highgui/src/window.cpp, line 271
Traceback (most recent call last):
File "camera_test.py", line 21, in <module>
  cv2.imshow('frame', frame)
cv2.error: /home/cro/opencv-3.0.0/modules/highgui/src/window.cpp:271: error: (-215) size.width>0 && size.height>0 in function imshow

我检查了操作系统是否使用lsusb.py在/ usr / bin下找到了相机:

[cro@centos7-home ~]$ lsusb.py
usb1            1d6b:0002 09  2.00  480MBit/s 0mA 1IFs (Linux 3.10.0-327.36.3.el7.x86_64 xhci-hcd xHCI Host Controller 0000:00:14.0) hub
usb2            1d6b:0003 09  3.00 5000MBit/s 0mA 1IFs (Linux 3.10.0-327.36.3.el7.x86_64 xhci-hcd xHCI Host Controller 0000:00:14.0) hub
usb3            1d6b:0002 09  2.00  480MBit/s 0mA 1IFs (ehci_hcd 0000:00:1a.0) hub
 3-1            8087:0024 09  2.00  480MBit/s 0mA 1IFs (Intel Corp. Integrated Rate Matching Hub) hub
  3-1.1         1778:0204 ef  2.00  480MBit/s 300mA 3IFs (IPEVO corp IPEVO Point 2 View)
  3-1.2         7392:7811 00  2.00  480MBit/s 500mA 1IFs (Realtek 802.11n WLAN Adapter 00e04c000001)
usb4            1d6b:0002 09  2.00  480MBit/s 0mA 1IFs (ehci_hcd 0000:00:1d.0) hub
 4-1            8087:0024 09  2.00  480MBit/s 0mA 1IFs (Intel Corp. Integrated Rate Matching Hub) hub
  4-1.4         0b05:17dc e0  2.10   12MBit/s 500mA 2IFs (Realtek  Bluetooth Radio  00e04c000001)

似乎是OpenCV的问题,我该如何获得框架?

0 个答案:

没有答案