Ask Your Question
1

Explain a simple code

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

tica1608 gravatar image

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

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
2

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

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
2

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

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

Stats

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

Seen: 313 times

Last updated: Jan 27 '14