program code is as follows:
// 导入图像
std::stringstream ss;
ss << "/home/wang/桌面/LearningVO-master/build/dataset/00/image_0/"
<< std::setw(6) << std::setfill('0') << img_id << ".png";
cv::Mat img(cv::imread(ss.str().c_str(), 0));
assert(!img.empty());
picture path is as follows:
but the program will assert failed.
my solution:
OpenCV absolute path seems to be a problem, change the absolute path to relative path:
// 导入图像
std::stringstream ss;
ss << "./dataset/00/image_0/"
<< std::setw(6) << std::setfill('0') << img_id << ".png";
cv::Mat img(cv::imread(ss.str().c_str(), 0));
assert(!img.empty());
note that this relative path is relative to the path to execute the command in the terminal; Also write “/Home/ XXX/” instead of” ~/ XXX/” in the Home directory, otherwise an error will occur.
modified, the program runs normally.
p>
Read More:
- @Value gets the configuration file value and returns null
- Opencv: 0xc0000005: an access conflict occurred while reading location 0x0000000010
- How to Solve mybatis returns null when querying Oracle database with char type field
- Reading and saving opencv Python video
- cv2.error: OpenCV(3.4.2) error: (-215:Assertion failed) !empty() in function ‘detectMultiScale‘
- Opencv453 drawing rectangle function error reporting solution
- OpenCV error: (-215:Assertion failed) !_src.empty() in function ‘cv::cvtColor‘
- Opencv problem: opencv error: assertion failed (! Empty()) in detectmultiscale
- [opencv + openvino] opencv-vino4.5.1 + opencv contrib installation
- Opencv perfect configuration strategy 2015 (win7 + opencv 2.4.9 + vs 2013)
- Project files may be invalid appears when cmake compiles opencv3.1, and the debug additional dependency of the compiled opencv3.1 is at the end
- [Solved] CAP_IMAGES: can‘t find starting number (in the name of file)
- Undefined reference to ‘CV:: imread (CV:: String const & int)’
- AttributeError: module ‘scipy.misc’ has no attribute ‘imread’
- After changing tomcat, the previous images cannot be displayed. All 404,
- Python data cleaning — delete failed images__ Simple version
- Error:null value in entry: incrementalFolder=null
- org.apache.ibatis.type.TypeException: Error setting non null for parameter #4 with JdbcType null