WhyCan Forum(哇酷论坛)

人过留名,雁过留声,感谢各位朋友不离不弃地支持。 QQ: 516333132, 微信: whycan_cn (哇酷网/挖坑网/填坑网) admin@whycan.cn

您尚未登录。

#1 2019-11-20 16:14:20

太一酱鸭
会员
注册时间: 2019-07-03
累计积分: 154

v3s bsp用opencv使用摄像头失败

用fswebcam是能够获取到图像的,但是opencv 不可以 ,打开语句用的这一条 VideoCapture *camera = new VideoCapture(0);

[   13.632458] [VFE]vfe_open
[   13.635462] [VFE]..........................vfe clk open!.......................
[   13.651111] [VFE]vfe_open ok
[   13.654469] [VFE]vfe_close
[   13.657545] [VFE]vfe select input flag = 0, s_input have not be used .
[   13.664984] [VFE]..........................vfe clk close!.......................
[   13.690047] [VFE]vfe_close end
[   13.693753] [VFE]vfe_open
[   13.696740] [VFE]..........................vfe clk open!.......................
[   13.720320] [VFE]vfe_open ok
[   13.723715] [VFE_ERR]input index(-1) > dev->dev_qty(1)-1 invalid!
[   13.740066] [VFE_ERR]stream has been already off
[   13.745345] [VFE]vfe_close
[   13.748413] [VFE]vfe select input flag = 0, s_input have not be used .
[   13.755819] [VFE]..........................vfe clk close!.......................
[   13.770060] [VFE]vfe_close end
Unable to stop the stream.: Bad file descriptor
VIDIOC_G_FMT: Bad file descriptor
unknown input size.#

然后尝试更换VideoCapture *camera = new VideoCapture(“/dev/video0”);

                                                                                                    
[   23.273289] [VFE]vfe_open
[   23.276292] [VFE]..........................vfe clk open!.......................
[   23.291123] [VFE]vfe_open ok
[   23.294623] [VFE_ERR]csi is not generating!
[   23.299417] [VFE]vfe_close
[   23.302556] [VFE]vfe select input flag = 0, s_input have not be used .
[   23.309941] [VFE]..........................vfe clk close!.......................
[   23.330043] [VFE]vfe_close end
unknown input size.#

离线

#2 2019-11-20 19:03:24

超级萌新
会员
注册时间: 2018-05-04
累计积分: 396

Re: v3s bsp用opencv使用摄像头失败

全志的camera是标准的v4l2接口,按理来说是不会有问题的。

离线

#3 2019-11-21 14:32:07

太一酱鸭
会员
注册时间: 2019-07-03
累计积分: 154

Re: v3s bsp用opencv使用摄像头失败

重新编译了一下,出现一堆

[  724.276203] [VFE]vfe_open
[  724.279374] [VFE]..........................vfe clk open!.......................
[  724.305184] [VFE]vfe_open ok
[  724.309779] [VFE]vfe_close
[  724.312938] [VFE]vfe select input flag = 0, s_input have not be used .
[  724.320345] [VFE]..........................vfe clk close!.......................
[  724.329319] [VFE]vfe_close end
[  724.351358] [VFE]vfe_open
[  724.354363] [VFE]..........................vfe clk open!.......................
[  724.380327] [VFE]vfe_open ok
[  724.410704] [VFE_ERR]input index(-1) > dev->dev_qty(1)-1 invalid!
[  724.436653] [VFE_WARN]v4l2 sub device queryctrl (null) unsuccess!
[  724.450528] [VFE_WARN]v4l2 sub device queryctrl (null) unsuccess!
[  724.457403] [VFE_WARN]v4l2 sub device queryctrl Brightness unsuccess!
[  724.480074] [VFE_WARN]v4l2 sub device queryctrl Contrast unsuccess!
[  724.487125] [VFE_WARN]v4l2 sub device queryctrl Saturation unsuccess!
[  724.500057] [VFE_WARN]v4l2 sub device queryctrl Hue unsuccess!
[  724.506618] [VFE_WARN]v4l2 sub device queryctrl (null) unsuccess!
[  724.530050] [VFE_WARN]v4l2 sub device queryctrl Volume unsuccess!
[  724.536966] [VFE_WARN]v4l2 sub device queryctrl Balance unsuccess!
[  724.550198] [VFE_WARN]v4l2 sub device queryctrl Bass unsuccess!
[  724.556918] [VFE_WARN]v4l2 sub device queryctrl Treble unsuccess!
[  724.580058] [VFE_WARN]v4l2 sub device queryctrl Mute unsuccess!
[  724.586782] [VFE_WARN]v4l2 sub device queryctrl Loudness unsuccess!
[  724.605210] [VFE_WARN]v4l2 sub device queryctrl Black Level unsuccess!
[  724.612882] [VFE_WARN]v4l2 sub device queryctrl Do White Balance unsuccess!
[  724.630063] [VFE_WARN]v4l2 sub device queryctrl Red Balance unsuccess!
[  724.637465] [VFE_WARN]v4l2 sub device queryctrl Blue Balance unsuccess!
[  724.650204] [VFE_WARN]v4l2 sub device queryctrl Gamma unsuccess!
[  724.656976] [VFE_WARN]v4l2 sub device queryctrl Gain, Automatic unsuccess!
[  724.680084] [VFE_WARN]v4l2 sub device queryctrl Horizontal Center unsuccess!
[  724.687997] [VFE_WARN]v4l2 sub device queryctrl Vertical Center unsuccess!
[  724.700186] [VFE_WARN]v4l2 sub device queryctrl Power Line Frequency unsuccess!
[  724.708450] [VFE_WARN]v4l2 sub device queryctrl Hue, Automatic unsuccess!
[  724.730183] [VFE_WARN]v4l2 sub device queryctrl White Balance Temperature unsuccess!
[  724.738935] [VFE_WARN]v4l2 sub device queryctrl Sharpness unsuccess!
[  724.760059] [VFE_WARN]v4l2 sub device queryctrl Backlight Compensation unsuccess!
[  724.768520] [VFE_WARN]v4l2 sub device queryctrl Chroma AGC unsuccess!
[  724.780065] [VFE_WARN]v4l2 sub device queryctrl Color Killer unsuccess!
[  724.787510] [VFE_WARN]v4l2 sub device queryctrl Brightness, Automatic unsuccess!
[  724.810046] [VFE_WARN]v4l2 sub device queryctrl Band-Stop Filter unsuccess!
[  724.817931] [VFE_WARN]v4l2 sub device queryctrl Rotate unsuccess!
[  724.840077] [VFE_WARN]v4l2 sub device queryctrl Background Color unsuccess!
[  724.847962] [VFE_WARN]v4l2 sub device queryctrl Chroma Gain unsuccess!
[  724.870058] [VFE_WARN]v4l2 sub device queryctrl Illuminator 1 unsuccess!
[  724.877648] [VFE_WARN]v4l2 sub device queryctrl Illuminator 2 unsuccess!
[  724.890056] [VFE_WARN]v4l2 sub device queryctrl Min Number of Capture Buffers unsuccess!
[  724.899120] [VFE_WARN]v4l2 sub device queryctrl Min Number of Output Buffers unsuccess!
[  724.940041] [VFE_WARN]v4l2 sub device queryctrl Alpha Component unsuccess!
[  724.947832] [VFE_WARN]v4l2 sub device queryctrl Horizontal Flip For Thumb unsuccess!
[  724.970062] [VFE CCI_0 ERR] Status error at addr_8bit = 42, wr_flag = 0, val = fad4a024
[  724.979710] [VFE CCI_0 ERR] Status error at addr_8bit = 42, wr_flag = 0, val = fad4a024
[  724.989203] [VFE CCI_0 ERR] Status error at addr_8bit = 42, wr_flag = 0, val = fad4a024
[  724.998199] [CSI_ERR][GC0308]error at sensor_write_array
[  725.004249] [VFE_ERR]bsp_csi_set_fmt error at vidioc_s_fmt_vid_cap!
libv4l2: error setting pixformat[  725.066330] [VFE]vfe_close
: Operation not permitted
HIGHG[  725.072022] [VFE]vfe select input flag = 0, s_input have not be used .
UI ERROR: libv4l unable to ioctl[  725.082120] [VFE]..........................vfe clk close!.......................
 S_FMT
[  725.096103] [VFE]vfe_close end
[  725.111997] [VFE]vfe_open
[  725.114998] [VFE]..........................vfe clk open!.......................
[  725.140315] [VFE]vfe_open ok
[  725.145035] [VFE_ERR]input index(-1) > dev->dev_qty(1)-1 invalid!
[  725.160525] [VFE_WARN]v4l2 sub device queryctrl (null) unsuccess!
[  725.167622] [VFE_ERR]size is too large,automatically set to maximum!
[  725.190233] [VFE_ERR]size is too large,automatically set to maximum!
[  725.197387] [VFE_ERR]size is too large,automatically set to maximum!
[  725.215233] [VFE_ERR]size is too large,automatically set to maximum!
[  725.222659] [VFE_ERR]size is too large,automatically set to maximum!
[  725.229804] [VFE_ERR]size is too large,automatically set to maximum!
[  725.250111] [VFE_ERR]size is too large,automatically set to maximum!
[  725.257283] [VFE_ERR]size is too large,automatically set to maximum!
[  725.280073] [VFE_ERR]size is too large,automatically set to maximum!
[  725.287239] [VFE_ERR]size is too large,automatically set to maximum!
[  725.300204] [VFE_ERR]size is too large,automatically set to maximum!
[  725.307424] [VFE_ERR]size is too large,automatically set to maximum!
[  725.330057] [VFE_ERR]size is too large,automatically set to maximum!
[  725.337283] [VFE_ERR]size is too large,automatically set to maximum!
[  725.350073] [VFE_ERR]size is too large,automatically set to maximum!
[  725.357286] [VFE_ERR]size is too large,automatically set to maximum!
[  725.380043] [VFE_ERR]size is too large,automatically set to maximum!
[  725.387260] [VFE_ERR]size is too large,automatically set to maximum!
[  725.400194] [VFE_ERR]size is too large,automatically set to maximum!
[  725.407409] [VFE_ERR]size is too large,automatically set to maximum!
[  725.430055] [VFE_ERR]size is too large,automatically set to maximum!
[  725.437210] [VFE_ERR]size is too large,automatically set to maximum!
[  725.450190] [VFE_ERR]size is too large,automatically set to maximum!
[  725.457341] [VFE_ERR]size is too large,automatically set to maximum!
[  725.480052] [VFE_ERR]size is too large,automatically set to maximum!
[  725.487358] [VFE_ERR]size is too large,automatically set to maximum!
[  725.500203] [VFE_ERR]size is too large,automatically set to maximum!
[  725.507419] [VFE_ERR]size is too large,automatically set to maximum!
[  725.530185] [VFE_ERR]size is too large,automatically set to maximum!
[  725.537401] [VFE_ERR]size is too large,automatically set to maximum!
[  725.560056] [VFE_ERR]size is too large,automatically set to maximum!
[  725.567273] [VFE_ERR]size is too large,automatically set to maximum!
[  725.580193] [VFE_ERR]size is too large,automatically set to maximum!
[  725.587413] [VFE_ERR]size is too large,automatically set to maximum!
[  725.610055] [VFE_ERR]size is too large,automatically set to maximum!
[  725.617272] [VFE_ERR]size is too large,automatically set to maximum!
[  725.630188] [VFE_ERR]size is too large,automatically set to maximum!
[  725.637344] [VFE_ERR]size is too large,automatically set to maximum!
[  725.660044] [VFE_ERR]size is too large,automatically set to maximum!
[  725.667195] [VFE_ERR]size is too large,automatically set to maximum!
[  725.680195] [VFE_ERR]size is too large,automatically set to maximum!
[  725.687342] [VFE_ERR]size is too large,automatically set to maximum!
[  725.710057] [VFE_ERR]size is too large,automatically set to maximum!
[  725.717273] [VFE_ERR]size is too large,automatically set to maximum!
[  725.730222] [VFE_ERR]size is too large,automatically set to maximum!
[  725.737440] [VFE_ERR]size is too large,automatically set to maximum!
[  725.760058] [VFE_ERR]size is too large,automatically set to maximum!
[  725.767274] [VFE_ERR]size is too large,automatically set to maximum!
[  725.780188] [VFE_ERR]size is too large,automatically set to maximum!
[  725.787440] [VFE_ERR]size is too large,automatically set to maximum!
[  725.815093] [VFE_ERR]size is too large,automatically set to maximum!
[  725.822530] [VFE_ERR]size is too large,automatically set to maximum!
[  725.829746] [VFE_ERR]size is too large,automatically set to maximum!
[  725.840216] [VFE_ERR]size is too large,automatically set to maximum!
[  725.847440] [VFE_ERR]size is too large,automatically set to maximum!
[  725.870066] [VFE_ERR]size is too large,automatically set to maximum!
[  725.877283] [VFE_ERR]size is too large,automatically set to maximum!
[  725.890232] [VFE_ERR]size is too large,automatically set to maximum!
[  725.897454] [VFE_ERR]size is too large,automatically set to maximum!
[  725.920086] [VFE_ERR]size is too large,automatically set to maximum!
[  725.927245] [VFE_ERR]size is too large,automatically set to maximum!
[  725.940220] [VFE_ERR]size is too large,automatically set to maximum!
[  725.947383] [VFE_ERR]size is too large,automatically set to maximum!
[  725.970078] [VFE_ERR]size is too large,automatically set to maximum!
[  725.977239] [VFE_ERR]size is too large,automatically set to maximum!
[  725.990225] [VFE_ERR]size is too large,automatically set to maximum!
[  725.997383] [VFE_ERR]size is too large,automatically set to maximum!
[  726.020105] [VFE_ERR]size is too large,automatically set to maximum!
[  726.027331] [VFE_ERR]size is too large,automatically set to maximum!
[  726.040240] [VFE_ERR]size is too large,automatically set to maximum!
[  726.047592] [VFE_ERR]size is too large,automatically set to maximum!
[  726.070061] [VFE_ERR]size is too large,automatically set to maximum!
[  726.077278] [VFE_ERR]size is too large,automatically set to maximum!
[  726.090190] [VFE_ERR]size is too large,automatically set to maximum!
[  726.097402] [VFE_ERR]size is too large,automatically set to maximum!
[  726.115215] [VFE_ERR]size is too large,automatically set to maximum!
[  726.130054] [VFE_ERR]size is too large,automatically set to maximum!
[  726.137266] [VFE_ERR]size is too large,automatically set to maximum!
[  726.150190] [VFE_ERR]size is too large,automatically set to maximum!
[  726.157406] [VFE_ERR]size is too large,automatically set to maximum!
[  726.180061] [VFE_ERR]size is too large,automatically set to maximum!
[  726.187282] [VFE_ERR]size is too large,automatically set to maximum!
[  726.200204] [VFE_ERR]size is too large,automatically set to maximum!
[  726.207419] [VFE_ERR]size is too large,automatically set to maximum!
[  726.230056] [VFE_ERR]size is too large,automatically set to maximum!
[  726.237202] [VFE_ERR]size is too large,automatically set to maximum!
[  726.250263] [VFE_ERR]size is too large,automatically set to maximum!
[  726.257422] [VFE_ERR]size is too large,automatically set to maximum!
[  726.280060] [VFE_ERR]size is too large,automatically set to maximum!
[  726.287214] [VFE_ERR]size is too large,automatically set to maximum!
[  726.300195] [VFE_ERR]size is too large,automatically set to maximum!
[  726.307410] [VFE_ERR]size is too large,automatically set to maximum!
[  726.330050] [VFE_ERR]size is too large,automatically set to maximum!
[  726.337268] [VFE_ERR]size is too large,automatically set to maximum!
[  726.350226] [VFE_ERR]size is too large,automatically set to maximum!
[  726.357432] [VFE_ERR]size is too large,automatically set to maximum!
[  726.380045] [VFE_ERR]size is too large,automatically set to maximum!
[  726.387263] [VFE_ERR]size is too large,automatically set to maximum!
[  726.400192] [VFE_ERR]size is too large,automatically set to maximum!
[  726.407407] [VFE_ERR]size is too large,automatically set to maximum!
[  726.430174] [VFE_ERR]size is too large,automatically set to maximum!
[  726.437325] [VFE_ERR]size is too large,automatically set to maximum!
[  726.460062] [VFE_ERR]size is too large,automatically set to maximum!
[  726.467216] [VFE_ERR]size is too large,automatically set to maximum!
[  726.480189] [VFE_ERR]size is too large,automatically set to maximum!
[  726.487343] [VFE_ERR]size is too large,automatically set to maximum!
[  726.510061] [VFE_ERR]size is too large,automatically set to maximum!
[  726.517274] [VFE_ERR]size is too large,automatically set to maximum!
[  726.530188] [VFE_ERR]size is too large,automatically set to maximum!
[  726.537402] [VFE_ERR]size is too large,automatically set to maximum!
[  726.560054] [VFE_ERR]size is too large,automatically set to maximum!
[  726.567271] [VFE_ERR]size is too large,automatically set to maximum!
[  726.580199] [VFE_ERR]size is too large,automatically set to maximum!
[  726.587416] [VFE_ERR]size is too large,automatically set to maximum!
[  726.610056] [VFE_ERR]size is too large,automatically set to maximum!
[  726.617276] [VFE_ERR]size is too large,automatically set to maximum!
[  726.630062] [VFE_ERR]size is too large,automatically set to maximum!
[  726.637211] [VFE_ERR]size is too large,automatically set to maximum!
[  726.660214] [VFE_ERR]input index(1) > dev->dev_qty(1)-1 invalid!
[  726.666993] [VFE_ERR]input index(1) > dev->dev_qty(1)-1 invalid!
[  726.680483] [VFE_WARN]v4l2 sub device queryctrl Hue unsuccess!
[  726.687055] [VFE_WARN]v4l2 sub device queryctrl Saturation unsuccess!
[  726.715074] [VFE_WARN]v4l2 sub device queryctrl Contrast unsuccess!
[  726.722344] [VFE_WARN]v4l2 sub device queryctrl Gamma unsuccess!
[  726.729163] [VFE_WARN]v4l2 sub device queryctrl Brightness unsuccess!
[  726.750132] [VFE_WARN]v4l2 sub device queryctrl Brightness unsuccess!
[  726.757375] [VFE_WARN]v4l2 sub device queryctrl Hue unsuccess!
[  726.770061] [VFE_WARN]v4l2 sub device queryctrl Contrast unsuccess!
[  726.777107] [VFE_WARN]v4l2 sub device queryctrl Saturation unsuccess!
[  726.800043] [VFE_WARN]v4l2 sub device queryctrl Gamma unsuccess!
HIGHGUI ERROR: libv4l unable to [  726.807169] [VFE]vfe_close
ioctl VIDIOCSPICT

[  726.812916] [VFE]vfe select input flag = 0, s_input have not be used .
[  726.822123] [VFE]..........................vfe clk close!.......................
[  726.840073] [VFE]vfe_close end

离线

#4 2019-11-21 14:43:43

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 8,947

Re: v3s bsp用opencv使用摄像头失败

彩虹派启动就运行一个相机程序, 应该不是camdroid, 里面有编译 ffmpeg, 但是不知道能不能用, 要不要参考一下:

https://github.com/qq516333132/rainbow-pi-sdk

离线

#5 2019-11-21 14:44:40

太一酱鸭
会员
注册时间: 2019-07-03
累计积分: 154

Re: v3s bsp用opencv使用摄像头失败

fswebcam是可以用的,主要要用opencv有问题

离线

#6 2019-11-21 14:47:27

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 8,947

Re: v3s bsp用opencv使用摄像头失败

只能这样强行解释一下: 驱动刚好实现了fswebcam必须的接口, opencv 调用了其他ioctl 命令, 这些在驱动没有实现,然后狗带?

离线

#7 2019-11-21 14:54:20

太一酱鸭
会员
注册时间: 2019-07-03
累计积分: 154

Re: v3s bsp用opencv使用摄像头失败

晕哥说的有道理,我在重新编译opencv了

离线

#8 2019-11-22 09:26:41

太一酱鸭
会员
注册时间: 2019-07-03
累计积分: 154

Re: v3s bsp用opencv使用摄像头失败

重新编译之后还是不行,问了三个以上在全志芯片上用opencv的人,全都是v4l底层调用的,没有用这条语句,顺带一提,这条语句在主线摄像头上是可以通过的。然后换荔枝派zero那个可以用的固件,这条语句同样不可以执行。

离线

#9 2019-11-22 09:44:14

jimmy
Moderator
注册时间: 2017-10-29
累计积分: 314

Re: v3s bsp用opencv使用摄像头失败

是哪一条语句呢?

离线

#10 2019-11-22 12:56:18

太一酱鸭
会员
注册时间: 2019-07-03
累计积分: 154

Re: v3s bsp用opencv使用摄像头失败

jimmy 说:

是哪一条语句呢?

VideoCapture *camera = new VideoCapture(0);

离线

#11 2019-11-22 13:42:58

jimmy
Moderator
注册时间: 2017-10-29
累计积分: 314

Re: v3s bsp用opencv使用摄像头失败

VideoCapture() 在 opencv 里面是怎么实现的?跟踪进去看看是什么情况, 哪里出错了。

离线

#12 2019-11-22 16:04:44

太一酱鸭
会员
注册时间: 2019-07-03
累计积分: 154

Re: v3s bsp用opencv使用摄像头失败

jimmy 说:

VideoCapture() 在 opencv 里面是怎么实现的?跟踪进去看看是什么情况, 哪里出错了。

if (-1 == xioctl (capture->deviceHandle, VIDIOC_S_FMT, &capture->form)) {
      fprintf(stderr, "HIGHGUI ERROR: libv4l unable to ioctl S_FMT\n");
      return -1;
  }
这里有问题

离线

#13 2019-11-22 17:02:15

jimmy
Moderator
注册时间: 2017-10-29
累计积分: 314

Re: v3s bsp用opencv使用摄像头失败

这个是设置摄像头输出格式的吧,按理来说一定会实现这个命令。确认驱动没有实现吗?

离线

#14 2019-11-23 10:09:31

太一酱鸭
会员
注册时间: 2019-07-03
累计积分: 154

Re: v3s bsp用opencv使用摄像头失败

jimmy 说:

这个是设置摄像头输出格式的吧,按理来说一定会实现这个命令。确认驱动没有实现吗?

驱动应该是实现了的,所以在想是不是opencv底层调用问题

离线

#15 2019-11-26 13:43:18

太一酱鸭
会员
注册时间: 2019-07-03
累计积分: 154

Re: v3s bsp用opencv使用摄像头失败

解决是底层调用问题,一个是s_fmt设置,将opencv底层从xioctl改成ioctl。接下来还出了一个错一个是s_ctrl的问题类似这样,全志自己修改了videodev2.h文件导致control有问题,继续在opencv底层改这个函数改成即使=-1不退出继续进行。

离线

#16 2019-11-26 13:44:16

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 8,947

Re: v3s bsp用opencv使用摄像头失败

太一酱鸭 说:

解决是底层调用问题,一个是s_fmt设置,将opencv底层从xioctl改成ioctl。接下来还出了一个错一个是s_ctrl的问题类似这样,全志自己修改了videodev2.h文件导致control有问题,继续在opencv底层改这个函数改成即使=-1不退出继续进行。

感谢分享!

离线

#17 2019-12-17 14:13:31

太一酱鸭
会员
注册时间: 2019-07-03
累计积分: 154

Re: v3s bsp用opencv使用摄像头失败

来反馈一下后续情况,并没有成功使用,最后还是v4l2底层调用获取图片了,bsp驱动并不能和opencv匹配。
只能将目前发现的问题暂时和大家分享一下。
1、必须指定vidioc_s_input设置,opencv只做了g_input。
2、我的摄像头驱动即使设置了不支持的格式也不会返回错误,cap_v4l会一开始就尝试设置这个格式,返回错误才接着设置其他格式。摄像头并不支持BGR24但没有返回错误导致最后取不到帧或者帧全黑。
但是这里我即使注释掉其余的把摄像头帧格式设置成UYVY(cap_v4l会自行做UYVY_TO_BGR的转换),获取到的图片会有四小块且是绿色的。目前找不到错误在哪,所以直接放弃更改cap_v4l.cpp。
注:之前我勾选了buildroot里的libv4l,opencv就会编译cap_libv4l.cpp来进行v4l2调用,不推荐这个,因为这个只支持bgr24没有格式转换代码。

离线

#18 2019-12-17 14:22:13

微凉VeiLiang
会员
注册时间: 2018-10-28
累计积分: 241

Re: v3s bsp用opencv使用摄像头失败

感谢分享经验,学习了

离线

#19 2019-12-17 15:00:36

Jmhh247
会员
注册时间: 2018-12-21
累计积分: 205

Re: v3s bsp用opencv使用摄像头失败

请教,你用buildroot哪个版本

buildroot里面的opencv,需要特别配置吗,我配置不成功


我试过buildroot2017 编译opencv,程序可以编译通过,但是放在v3s运行会出错:

# ./testopencv
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/vmzys/work/2019/my_imx6ul/code-build/rootfs/buildroot-2017.08.1/output/build/opencv3-3.2.0/modules/highgui/src/window.cpp, line 565
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/vmzys/work/2019/my_imx6ul/code-build/rootfs/buildroot-2017.08.1/output/build/opencv3-3.2.0/modules/highgui/src/window.cpp:565: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow

Aborted
#







太一酱鸭 说:

来反馈一下后续情况,并没有成功使用,最后还是v4l2底层调用获取图片了,bsp驱动并不能和opencv匹配。
只能将目前发现的问题暂时和大家分享一下。
1、必须指定vidioc_s_input设置,opencv只做了g_input。
2、我的摄像头驱动即使设置了不支持的格式也不会返回错误,cap_v4l会一开始就尝试设置这个格式,返回错误才接着设置其他格式。摄像头并不支持BGR24但没有返回错误导致最后取不到帧或者帧全黑。
但是这里我即使注释掉其余的把摄像头帧格式设置成UYVY(cap_v4l会自行做UYVY_TO_BGR的转换),获取到的图片会有四小块且是绿色的。目前找不到错误在哪,所以直接放弃更改cap_v4l.cpp。
注:之前我勾选了buildroot里的libv4l,opencv就会编译cap_libv4l.cpp来进行v4l2调用,不推荐这个,因为这个只支持bgr24没有格式转换代码。

离线

#20 2019-12-17 15:42:39

太一酱鸭
会员
注册时间: 2019-07-03
累计积分: 154

Re: v3s bsp用opencv使用摄像头失败

Jmhh247 说:

请教,你用buildroot哪个版本

buildroot里面的opencv,需要特别配置吗,我配置不成功


我试过buildroot2017 编译opencv,程序可以编译通过,但是放在v3s运行会出错:

# ./testopencv
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/vmzys/work/2019/my_imx6ul/code-build/rootfs/buildroot-2017.08.1/output/build/opencv3-3.2.0/modules/highgui/src/window.cpp, line 565
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/vmzys/work/2019/my_imx6ul/code-build/rootfs/buildroot-2017.08.1/output/build/opencv3-3.2.0/modules/highgui/src/window.cpp:565: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow

Aborted
#

你是不是用了cvNameWindow但是你没有编译图形界面库?你试试勾选buildroot里的libgtk,我没有用到图形界面所以没有用到这些

离线

#21 2019-12-17 16:11:24

Jmhh247
会员
注册时间: 2018-12-21
累计积分: 205

Re: v3s bsp用opencv使用摄像头失败

确实用到了cvNameWindow,程序只有简单几行:

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // read an image
    cv::Mat image = cv::imread("1.jpg", 1);
    // create image window named "My Image"
    cv::namedWindow("My Image 2019");
    // show the image on window
    cv::imshow("My Image2019", image);
}


这个 libgtk很尴尬,我也看到错误提示,但是buildroot里面根本找不到  libgtk2.0 !  ...可能是我姿势不对吧

下面我截个图
---
- buildroot里面可以搜索到 libgtk2:
serlibg.png

- 实际去选择找不到,也没任何依赖提示
lib2err.png


你能找到libgtk2吗

离线

#22 2019-12-17 17:19:45

太一酱鸭
会员
注册时间: 2019-07-03
累计积分: 154

Re: v3s bsp用opencv使用摄像头失败

你的依赖没有勾选,你看到depend on了吗,所有的选项都必须是Y

Jmhh247 说:

确实用到了cvNameWindow,程序只有简单几行:

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // read an image
    cv::Mat image = cv::imread("1.jpg", 1);
    // create image window named "My Image"
    cv::namedWindow("My Image 2019");
    // show the image on window
    cv::imshow("My Image2019", image);
}


这个 libgtk很尴尬,我也看到错误提示,但是buildroot里面根本找不到  libgtk2.0 !  ...可能是我姿势不对吧

下面我截个图
---
- buildroot里面可以搜索到 libgtk2:
https://whycan.cn/files/members/1331/serlibg.png

- 实际去选择找不到,也没任何依赖提示
https://whycan.cn/files/members/1331/lib2err.png


你能找到libgtk2吗

离线

#23 2019-12-18 08:34:35

Jmhh247
会员
注册时间: 2018-12-21
累计积分: 205

Re: v3s bsp用opencv使用摄像头失败

感谢指点,回头试试


太一酱鸭 说:

你的依赖没有勾选,你看到depend on了吗,所有的选项都必须是Y

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // read an image
    cv::Mat image = cv::imread("1.jpg", 1);
    // create image window named "My Image"
    cv::namedWindow("My Image 2019");
    // show the image on window
    cv::imshow("My Image2019", image);
}

离线

页脚