Ask Your Question

Explain a simple code

asked 2014-01-27 10:13:36 -0600

tica1608 gravatar image

updated 2014-01-27 10:48:29 -0600

berak gravatar image

I'm a newbie in OpenCV, so I don't understand when reading this code below. Please explain to me what it means.

uchar* ptr = (uchar*) (image->imageData + y*image->widthStep);
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2014-01-27 12:56:28 -0600

SpiderGears gravatar image

first note: Avoid this.

This code basically had pointer of type unsigned character which is assigned the address of the yth row of the image. the address is cast to Unsigned char type before assignment.

for IplImage structure

->imageData is the start of image data skipping the image header data

->widthStep is the size of a row of pixels in the image.

edit flag offensive delete link more

answered 2014-01-27 11:22:14 -0600

berak gravatar image

that seems to retrieve a pointer to row y in an old IplImage.

but honestly, you shouldn't be using code like that. they migrated to c++ 4 years ago, and so should you ..

if you see code, that's using IplImages, cv* functions, - avoid it, it's clearly outdated.

edit flag offensive delete link more

Question Tools


Asked: 2014-01-27 10:13:36 -0600

Seen: 425 times

Last updated: Jan 27 '14