Ask Your Question
0

Error running program

asked 2013-06-10 18:14:19 -0600

residentelvio gravatar image

Hi i m running a programm I finish . I see this as error:

   OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or
   unsupported array type) in cvGetMat, file
   /build/buildd/opencv-2.3.1/modules/core/src/array.cpp, line 2482 terminate
   called after throwing an instance of 'cv::Exception' what():
  /build/buildd/opencv-2.3.1/modules/core/src/array.cpp:2482: error: (-206)
  Unrecognized or unsupported array type in function cvGetMat

I suppose it s an error about the type of image I use. What I do is take an image and work with it in two different ways, for if the image is in grey scale or RBG. I suppose I did some errors with some functions need in paramethers the type. For example:

  img= image.zeros(rows,cols,CV_32F);

I don t know the difference in the last paramether (the type), can I use for example image.type() ? There is something it explain good the type in openCV. Thanks

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-06-10 19:22:13 -0600

I am not sure if image.zeros() is the way to go... according to the documentation you should do this:

cv::Mat img;
img = cv::Mat::zeros(rows, cols, CV_32F);

I hope this helps

edit flag offensive delete link more

Comments

it was just an example. Obviously I declared it as a Mat object.Howewer new version of OpenCV permit different use of functions

residentelvio gravatar imageresidentelvio ( 2013-06-10 20:51:29 -0600 )edit

P.S. I have no errors from compiler

residentelvio gravatar imageresidentelvio ( 2013-06-10 20:52:56 -0600 )edit

I didn t see that zeros is a static function. You have the reason. So can you help me to understand the different types of an image. There is a good explaination in the www? Because I have the same problem.

residentelvio gravatar imageresidentelvio ( 2013-06-10 21:05:49 -0600 )edit

Here you can find some documentation about the data types http://docs.opencv.org/modules/core/doc/intro.html#fixed-pixel-types-limited-use-of-templates

You can perfectly use this: img = cv::Mat::zeros(image.size(), image.type()) to create a matrix "img" filled with zeros with the same size and type as "image"

Martin Peris gravatar imageMartin Peris ( 2013-06-11 00:36:02 -0600 )edit

the cv:: with new version is not used, but as the function is static. It needs as you said Mat before zeros and not the object. I saw the document and I modified the part where I use the picture with a channel using CV_32FC1 and CV_32FC3 for the picture if it has 3 channels. In the project I use ubuntu and bitmpap image because they are compatible on every OS

residentelvio gravatar imageresidentelvio ( 2013-06-11 05:21:25 -0600 )edit

Well, the cv:: is not needed only if you define "using cv;", which I never do because I like knowing where my methods come from, it is just a matter of preference :) Cheers

Martin Peris gravatar imageMartin Peris ( 2013-06-11 19:32:33 -0600 )edit

Ok I ave onether question. THe image I use in my project must be in the same path of the project to work?

residentelvio gravatar imageresidentelvio ( 2013-06-13 06:17:23 -0600 )edit

Another doubt.... rows=img.rows; cols=img.cols; channels=img.channels();

Does this code give to me the numbers of cols, rows and channels of an image I loaded with imread?

residentelvio gravatar imageresidentelvio ( 2013-06-13 06:29:15 -0600 )edit
1

The image you use for imread() can be both relative as well as absolute. If you want to use relative path , you can give the path to image with starting point from current directory where you have a terminal running the object file (executable). You can also pass the absolute path as well to imread which will be like "/home/residentelvio/OpenCV/project_thesis/MyImage.extension"

And Yes. img.rows, img.cols, img.channels() give the rows,cols and channels for the img object if img is of cv::Mat type

And make sure you are loading the image using if statements to check. Errors can arise if the image is not in the given path to imread(). It is recommended to use img.empty() or img.data to verify whether you have loaded the image.

Prasanna gravatar imagePrasanna ( 2013-06-20 12:04:09 -0600 )edit

ok perfect

residentelvio gravatar imageresidentelvio ( 2013-06-20 13:43:20 -0600 )edit

Question Tools

Stats

Asked: 2013-06-10 18:14:19 -0600

Seen: 4,455 times

Last updated: Jun 10 '13