Ask Your Question
0

problem with reading image to Mat

asked 2013-08-14 14:06:06 -0600

ho_khalaf gravatar image

updated 2013-08-14 16:47:03 -0600

Im using Visual Studio 2012 with OpenCv 2.4.6 and I don't know if I'm doing sth wrong but I can't do the simplest imread(), because there is a problem with R6010 abort has been called

#include "mainwindow.h"
#include <QApplication>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

using namespace cv;

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    Mat img = imread("c:/a.jpg",1);
    imshow("window1",img);
    MainWindow w;
    w.show();

    return a.exec();
}

and this is the bug

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in unknown function, file C:\slave\builds\WinInstallerMegaPack\src\opencv\modules\highgui\src\window.cpp, line 261
edit retag flag offensive close merge delete

Comments

Please provide full code, all the settings that you did (linker, path variable, ...) and the exact line where it crashes also with the full debug error output. Then we might be able to help you out. About the tags, please try to leave the hashtags behind, they create doubles where it isn't needed.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-14 14:40:39 -0600 )edit
2

Your error states that the image wasn't read correctly. Please add the following lines to check for sure.

if( img.empty() ) {
  cout &lt;&lt; "Error occured, image not read correctly"
}
StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-14 16:50:19 -0600 )edit

what is the &lt. there is no lt in my cod??

ho_khalaf gravatar imageho_khalaf ( 2013-08-15 02:38:31 -0600 )edit
1

The "&lt;" are HTML entities for left angle brackets "<".

Neptilo gravatar imageNeptilo ( 2013-08-15 03:22:06 -0600 )edit

Thx for the help @Neptilo :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-15 03:45:24 -0600 )edit

I use the code and answer is "Error occured, image not read correctly"

ho_khalaf gravatar imageho_khalaf ( 2013-08-15 12:32:42 -0600 )edit

Then this means that your image is actually not on that location or it isnt found. Try to use a double backslash in stead of a front slash in your path.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-15 15:06:19 -0600 )edit

it not work."Error occured, image not read correctly"

ho_khalaf gravatar imageho_khalaf ( 2013-08-15 15:56:47 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-08-14 14:12:28 -0600

engine gravatar image

I'm using the same version of opencv and VS and I don't have a problem you shohould put your code to be sure that's not the reason of your Problem

edit flag offensive delete link more

Comments

hi thanks for your attention. i use it in QtCreator and i have this problem in visual studio i dont have any problem. i use this to solve problem IplImage* img1 = cvLoadImage("c:/a.jpg",1); Mat img(img1);

ho_khalaf gravatar imageho_khalaf ( 2013-08-14 14:39:52 -0600 )edit

Question Tools

Stats

Asked: 2013-08-14 14:06:06 -0600

Seen: 5,106 times

Last updated: Aug 14 '13