发布时间:2023-06-07 08:00
用pkg-config --modversion opencv
命令,查看opencv版本,提示找不到
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
报错原因:是因为没有找到opencv.pc,而刷机时是安装了OpenCV的,不过是OpenCV4,在/usr/lib/aarch64-linux-gnu/pkgconfig中找到了opencv4.pc
采用如下命令查看nx板中opencv版本,可知为opencv4
dpkg -l libopencv
将pkg-config的命令修改为opencv4即可正常使用
pkg-config --modversion opencv4
#include "opencv2\opencv.hpp"
#include
using namespace cv;
int main()
{
VideoCapture capture;
//capture.open("../../bin/data/1.mp4");
capture.open("rtsp://admin:admin123@192.168.1.164:554/cam/realmonitor?channel=1&subtype=0");
int frameH = capture.get(4);
int frameW = capture.get(3);
std::cout << "frameH:" << frameH << " frameW:" << frameW << std::endl;
while (1)
{
Mat frame;
capture >> frame;
if (frame.empty())
{
break;
}
imshow("test", frame);
waitKey(30);
}
}
注意,此处要写为opencv4
g++ -o Main capture_video.cpp `pkg-config opencv4 --libs --cflags`
cmake_minimum_required(VERSION 2.8)
find_package(OpenCV)
include_directories(OpenCV_INCLUDE_DIRS)
message(${OpenCV_INCLUDE_DIRS})
message(${OpenCV_LIBRARIES})
add_definitions("-Wall -std=c++11")
add_executable(Main capture_video.cpp)
target_link_libraries(Main ${OpenCV_LIBRARIES})
mkdir build
cd build
cmake ..
make
参考文献
- Jetson AGX Xavier配置使用OpenCV(报错:No package ‘opencv’ found)
- opencv RTSP拉流