Ask Your Question
0

IplImage nChannels is always returning -1

asked 2013-01-29 02:36:33 -0600

manmedia gravatar image

updated 2020-11-11 11:34:37 -0600

Hello

Due to the restricted nature of my program I cannot post the code. However, I can provide a very apt description of it so that the problem can be understood.

I have an image processing application where I need to store history of image masks. There are total 6 mask images that fit into a mask history. a history is made via a pair which has an integer type of identifier and the IplImage* for the mask. For this I have created a vector as:

   std::vector<std::pair<int, IplImage*>> maskVal; // (int = type for the Id - #defined)

I can confirm that I can save the correct mask values in a history i.e. the channels are correct as as processed by my program. Also, I have in place built-in macros that will __STOP__ the program if mismatches such as nChannels value is wrong, image is NULL, incorrect number of mask images saved, etc. However, when I try to reload the mask values for processing all of them seems to have the nChannels = -1.

I don't know if saving them as IplImage rather than IplImage* would make any difference. I have unit tests that prove that my mask history can correctly load the masks but I am having trouble understanding why the channels are always being returned as -1 even though when they are saved with nChannels = 1.

I know this is probably not as detailed as you would expect but I will try and put some more information up to my limit. I would appreciate if someone points me to the right direction.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-01-31 15:19:13 -0600

manmedia gravatar image

I figured out the problem. Saving pointers and then calling them later in the design may not be a good idea eh? Also Deep Copy / Shallow Copy stuff!!

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-01-29 02:36:33 -0600

Seen: 304 times

Last updated: Jan 31 '13