我的老师为我提供了可能基于OpenCV 2或3的项目的源代码。
我尝试运行它,但出现错误:在此范围内未声明“cvSaveImage”。像这样:
root@qrh-pc:/home/qrh/文档/TrafficSignQtProgram/build# make
Scanning dependencies of target TREFFIC_SIGN_QT_PROJECT
[ 3%] Building CXX object bin/CMakeFiles/TREFFIC_SIGN_QT_PROJECT.dir/Camera.cpp.o
/home/qrh/文档/TrafficSignQtProgram/TrafficSignBlockCalProject/src/Camera.cpp: In member function ‘void CCamera::renderImage()’:
/home/qrh/文档/TrafficSignQtProgram/TrafficSignBlockCalProject/src/Camera.cpp:380:5: error: ‘cvSaveImage’ was not declared in this scope
cvSaveImage(imageSaveFileName.c_str(), img);
^~~~~~~~~~~
/home/qrh/文档/TrafficSignQtProgram/TrafficSignBlockCalProject/src/Camera.cpp:380:5: note: suggested alternative: ‘cvShowImage’
cvSaveImage(imageSaveFileName.c_str(), img);
^~~~~~~~~~~
cvShowImage
/home/qrh/文档/TrafficSignQtProgram/TrafficSignBlockCalProject/src/Camera.cpp: In member function ‘void CCamera::renderImage(CameraParams, pcl::PointCloud<pcl::PointXYZRGBL>::Ptr, pcl::PointIndices&)’:
/home/qrh/文档/TrafficSignQtProgram/TrafficSignBlockCalProject/src/Camera.cpp:511:5: error: ‘cvSaveImage’ was not declared in this scope
cvSaveImage(imageSaveFileName.c_str(), img);
^~~~~~~~~~~
/home/qrh/文档/TrafficSignQtProgram/TrafficSignBlockCalProject/src/Camera.cpp:511:5: note: suggested alternative: ‘cvShowImage’
cvSaveImage(imageSaveFileName.c_str(), img);
^~~~~~~~~~~
cvShowImage
/home/qrh/文档/TrafficSignQtProgram/TrafficSignBlockCalProject/src/Camera.cpp: In member function ‘void CCamera::renderImageCalOccludeCloud(CameraParams, pcl::PointCloud<pcl::PointXYZRGBL>::Ptr, pcl::PointCloud<pcl::PointXYZRGBL>::Ptr)’:
/home/qrh/文档/TrafficSignQtProgram/TrafficSignBlockCalProject/src/Camera.cpp:659:5: error: ‘cvSaveImage’ was not declared in this scope
cvSaveImage(imageSaveFileName.c_str(), img);
^~~~~~~~~~~
/home/qrh/文档/TrafficSignQtProgram/TrafficSignBlockCalProject/src/Camera.cpp:659:5: note: suggested alternative: ‘cvShowImage’
cvSaveImage(imageSaveFileName.c_str(), img);
^~~~~~~~~~~
cvShowImage
bin/CMakeFiles/TREFFIC_SIGN_QT_PROJECT.dir/build.make:81: recipe for target 'bin/CMakeFiles/TREFFIC_SIGN_QT_PROJECT.dir/Camera.cpp.o' failed
make[2]: *** [bin/CMakeFiles/TREFFIC_SIGN_QT_PROJECT.dir/Camera.cpp.o] Error 1
CMakeFiles/Makefile2:133: recipe for target 'bin/CMakeFiles/TREFFIC_SIGN_QT_PROJECT.dir/all' failed
make[1]: *** [bin/CMakeFiles/TREFFIC_SIGN_QT_PROJECT.dir/all] Error 2
Makefile:102: recipe for target 'all' failed
make: *** [all] Error 2
root@qrh-pc:/home/qrh/文档/TrafficSignQtProgram/build#
OpenVC 3.4是我的版本,我尝试包括许多头文件,但不起作用。#include "opencv2/opencv.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/videoio.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/imgproc/imgproc.hpp"
#include <opencv2/imgcodecs.hpp>
最佳答案
openCV2 支持cvSaveImage
。 openCV3 和 openCV4 中受支持的替代方法是imwrite
方法。有关更多信息,请检查此link
C++:
bool cv::imwrite ( const String & filename,
InputArray img,
const std::vector< int > & params = std::vector< int >()
)
Python:
retval = cv.imwrite( filename, img[, params] )
关于c++ - 在此范围OpenCV.4中未声明cvSaveImage,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/62809600/