Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opencv依赖库是不是缺了一些东西? #1

Open
B1D1ng opened this issue Jan 7, 2022 · 4 comments
Open

opencv依赖库是不是缺了一些东西? #1

B1D1ng opened this issue Jan 7, 2022 · 4 comments

Comments

@B1D1ng
Copy link

B1D1ng commented Jan 7, 2022

我打算先通过cv::imread读取jpg格式的图片,再通过cvtColor函数转成yuv格式最后喂给模型进行识别,发现imread这个函数读图片结果是空的,确认了图片、路径都没有问题,怀疑是不是opencv的库不全?

@BaronLeeLZP
Copy link
Owner

方案一:修改src/sample_nnie_api.cpp中的这个函数(同时):
`int yolo_run(unsigned char *input_yuv420_data, int input_w,int input_h)
{
Mat imgRGB;
Mat imgRect;
Mat imgYUV(input_h + input_h/2, input_w, CV_8UC1, input_yuv420_data);
cvtColor(imgYUV,imgRGB,COLOR_YUV2BGR_I420);
resize(imgRGB, imgRGB, cv::Size(416, 416));

std::vector<Rect> obj_post;
yolov3_inference(ppHandle, imgRGB);

return 0;

}改为int yolo_run(unsigned char *input_RGB_data, int input_w,int input_h)
{
Mat imgRGB(input_h, input_w, CV_8UC3, input_RGB_data);
resize(imgRGB, imgRGB, cv::Size(416, 416));

std::vector<Rect> obj_post;
yolov3_inference(ppHandle, imgRGB);

return 0;

}`
即输入图像为RGB格式,.jpg可以直接输入。重新make一下。
方案二:排查输入图像格式和逐步调试并打印信息。
优选方案一。

@B1D1ng
Copy link
Author

B1D1ng commented Jan 9, 2022

感谢回复,已解决,是因为之前工程编译的opencv库阉割了libjpeg库,我重新用一个完整环境的opencv库就解决imread问题了。但是有一个新的问题,请问您尝试过VideoCapture读取视频流来检测吗,虽然我使用了完整的opencv库,但是视频流还是无法读取到,有一个同学说有可能是编译3516dv300的内核的时候v4l相关选项没有勾选,但是我尝试勾选后发现编译内核无法成功了,无法读取视频流这个问题一直困扰着我

@BaronLeeLZP
Copy link
Owner

在嵌入式AI芯片上不建议使用opencv来处理视频流,HiSilicon有自己的媒体处理pipeline,去SDK demo和docs里找下。

@sin0803
Copy link

sin0803 commented Aug 23, 2022

您好,我下载了您的demo编译出来 test 程序。我把您整个demo 目录拷贝到开发板上,修改环境变量 LD_LIBRARY_PATH ,增加了 opencv 动态库路径,
/models/hi3516dv300_nnie-yolov3-demo # echo $LD_LIBRARY_PATH
/models/hi3516dv300_nnie-yolov3-demo/libopencv/lib:/usr/local/lib:/usr/lib:/models/lib
但是我执行程序时 总是提示opencv 库找不到,我看了 opencv 动态库的 文件类型是arm,是对的,请教一下您我是哪里操作错了么?
/models/hi3516dv300_nnie-yolov3-demo # ./test
./test: error while loading shared libraries: ../../lib/libopencv_imgcodecs.so: cannot open shared object file: No such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants