Linux: 兩個USB網路攝影機的資料擷取問題

來源:互聯網
上載者:User

 引子: 課題需要,同時採集兩個網路攝影機資料,頻率不高,但要同時。中間遇到的問題,唉一言難盡啊!

為了圖省事使用UVC網路攝影機,但是板子是USB1.1介面的,故挑選相容USB1.1的UVC驅動的網路攝影機,最終選定兩個301V晶片的網路攝影機,先使用一個網路攝影機,因頻率不高,將採集頻率設到了最低5幀每秒,開啟視頻流,正常!視頻緩衝出列,入列,正常!儲存映像,正常!再添加一個網路攝影機,先使用VIDIOC_STREAMON開啟一個網路攝影機,正常,再開啟另一個,報錯了!

出錯代碼:

uvcvideo: Failed to submit URB 0 (-28).

經查疑似頻寬不足,

(摘自http://answerpot.com/showthread.php?272129-Stream+from+multimple+cameras)

The uvcvideo driver requests bandwidth based on values reported by the camera.

There are two settings involved there. The first one is the alternate settings
for the video streaming interface. The video streaming interface has an
isochronous endpoint for video streaming, and each alternate setting has a
different maximum packet size for the endpoint, resulting in different
bandwidth requirements.

The second one is the dwMaxPayloadTransferSize value reported by the camera
when querying its video streaming control. The driver selects the alternate
setting with the lowest bandwidth that fulfills the dwMaxPayloadTransferSize
requirements.

If your camera has a single alternate setting (this can be checked using
lsusb) you're probably screwed, as the bandwidth is fixed. If it has multiple
alternate settings, it might be requesting a bandwidth higher than what it
really needs. In that case you could try to hardcode a lower bandwidth (see
the uvc_init_video function in uvc_video.c), or let the driver compute a
bandwidth estimation on its own by setting the UVC_QUIRK_FIX_BANDWIDTH quirk.

It's also possible to play with URB submission order to use higher bandwidths
and alternate capture between the different webcams. Dennis Muhlestein
investigated that and got interesting results. Search the list archives for a
thread called "Multiple camera framerate".

鬱悶數日,度日如年啊!一頭霧水,未解,唉,菜鳥嗎!難道吃菜的鳥真的飛不高嗎?或許天生就不是搞代碼的料。

後來的後來,試了試另外的兩個網路攝影機,301PL的,USB1.1介面,Linux2.6.28中包含了該類型網路攝影機的驅動(gspca,據說是位法國學者編的),同時開啟兩個網路攝影機,意想不到的是,報了3次錯後,開啟了

zc3xx: probe 2wr ov vga 0x0000
zc3xx: probe 2wr ov vga 0x0000
gspca: usb_submit_urb [0] err -28
s3c2410-ohci s3c2410-ohci: leak ed ff1d2140 (#81) state 2
zc3xx: probe 2wr ov vga 0x0000
gspca: usb_submit_urb [0] err -28
s3c2410-ohci s3c2410-ohci: leak ed ff1d2180 (#81) state 2
zc3xx: probe 2wr ov vga 0x0000
gspca: usb_submit_urb [0] err -28
s3c2410-ohci s3c2410-ohci: leak ed ff1d21c0 (#81) state 2
zc3xx: probe 2wr ov vga 0x0000
this is vidCapture_thread of Left
the 1 of Left
state at:978442537 719669
this is vidCapture_thread of right
the 1 of right
state at:978442537 823039

不知為什麼,但是對比UVC和gspca驅動的原始碼,發現對於usb_submit_urb () 函數的傳回值的處理是不同的,gspca中加了對錯誤碼的判斷,將28號錯誤(ENOSPC)同其他的區別對待了

/* submit the URBs */
 614                for (n = 0; n < gspca_dev->nurbs; n++) {
 615                        ret = usb_submit_urb(gspca_dev->urb[n], GFP_KERNEL);
 616                        if (ret < 0) {
 617                                PDEBUG(D_ERR|D_STREAM,
 618                                        "usb_submit_urb [%d] err %d", n, ret);
 619                                gspca_dev->streaming = 0;
 620                                destroy_urbs(gspca_dev);
 621                                if (ret == -ENOSPC)
 622                                        break;  /* try the previous alt */
 623                                goto out;
 624                        }
 625                }

而UVC中只要是提交沒成功就退出。

 

菜鳥只能將問題提出來,解決問題還要靠大俠們啊

 

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.