Click here to Skip to main content
15,885,910 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I work about opencv in visual studio 2008

I access imageData of grayscale image. The code is
int step = tempimage->widthStep;
uchar * data = (uchar *)tempimage->imageData;
if( (x+y*step+1+step)<(width+height*step) ){
        if( int(data[x+y*step+1+step])==0 )
            count++;
    }

but it have error

compiler tell data have value 255'.' and type unsigned

please help me how to solve this problem

thank.

-- update from OP --
Screenshot of error
http://img684.imageshack.us/i/cpopencvinvisualstudio2.png/[^]
(moved to Imageshack)
--
Posted
Updated 30-Jan-11 14:45pm
v3
Comments
Indivara 30-Jan-11 9:56am    
Where? Which line? Can you update the question with the full message?
Richard MacCutchan 30-Jan-11 10:23am    
This code works OK for me; try posting the exact compiler error you see and maybe we can help.
Indivara 30-Jan-11 20:42pm    
That is a runtime error, not a compiler error. Please update your question, don't add an answer (I'll update it this time)
bingz 30-Jan-11 21:19pm    
the value of the pixel should be 255 but it is 255'.'
Indivara 31-Jan-11 0:55am    
'.' is the debugger's interpretation of the value 255. As I said in the answer, the value is of no concern here. What matters is that you are reading from an invalid memory location (memory not allocated by your program)

 
Share this answer
 
That is probably because you are reading the array data[] beyond its length. In this case, the value 255 has no meaning, it is just some data that happens to be in the memory beyond the end of the array. Check the allocated length, and the array index when the error occurs.
 
Share this answer
 
Comments
bingz 31-Jan-11 0:28am    
i think array index is true because the first if condition check index of array must less than number of pixel in this image
Indivara 31-Jan-11 0:57am    
That may be so, but we couldn't possible comment based on the code fragment. Debug it further, put the address of data[] in the memory window (the one that allows you to monitor the memory contents), and see how it changes as you step through.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900