2015-04-03 69 views
0

我在我的筆記本電腦上使用Visual Studio和Ubuntu VM(使用CMake)在Windows上運行OpenCV code。代碼工作在兩個完全正常,但是當我嘗試在我的樹莓派2B運行,功能cvtColor()(線205),會導致以下錯誤:OpenCV:樹莓派上的cvtColor函數導致錯誤

[email protected] ~/Desktop/Track1 $ ./TrackObj 
init done 
opengl support available 
OpenCV Error: Assertion failed ((scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F)) in cvtColor, file /home/pi/opencv-2.4.10/modules/imgproc/src/color.cpp, line 3961 
terminate called after throwing an instance of 'cv::Exception' 
    what(): /home/pi/opencv-2.4.10/modules/imgproc/src/color.cpp:3961: error: (-215) (scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F) in function cvtColor 

Aborted 

我見過的建議,試圖檢查該框架是空的,但我不知道如何在this code中做到這一點,因爲它沒有運行。

我也嘗試將輸入從camera.open(0);更改爲camera.open("someMovieInFolder.mp4");,但問題依然存在。

回答

0

好吧,我明白了。事實上,問題在於圖像是空的,這就是導致運行時錯誤的原因。 原因是Pi相機。不幸的是,這個功能並不適用於Pi攝像頭(或者至少需要進行某些調整),因此在插入USB攝像頭之後,這一切都很完美。

+0

我通過安裝可用的V4L驅動程序[這裏](http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=14)讓我的工作。 – mkr 2015-04-07 20:21:43

2

它確實看起來好像圖像是空的。可以檢查圖像捕獲功能returns a boolean value以查看捕獲是否成功完成並返回了vaild圖像。你也可以嘗試printf或cout圖像的寬度/高度。它應該是非零的。