Ask Your Question
1

Graycode Pattern: Irregular and off-center??

asked 2020-03-23 12:48:43 -0600

blorgggg gravatar image

updated 2020-03-25 20:23:58 -0600

I have been struggling trying to get the Structured light examples going with Opencv (Windows 10, C++, Visual Studio). Something I have noticed when trying with multiple computers, projectors, and even using the Java version of OpenCV, the Graycode patterns it generates seem to be messed up (or there is something in the graycode theory I am missing).

My thoughts are that the graycode patterns should be something like 0) horizontal, left 50% pixels black, right 50% pixels white 0b) horizontal, inverse of previous 1)horizontal, left 25% pixels black, next 25% pixels white, next 25% pixels black, next 25% pixels white 1b)horizontal, inverse of previous ... and so on until there are single pixel wide stripes across then repeat for the vertical direction 0) vertical, top 50% pixels black, bottom 50% pixels white 0b) vertical, inverse of previous 1)vertical, top 25% pixels black, next 25% pixels white, next 25% pixels black, next 25% pixels white 1b)vertical, inverse of previous ...and so on until single pixel length strips and then a final -All Black Pixels -All White pixels

BUT

in each version of the generate graycode i try, the pixels are never divided how i would think (i am using the examples from the contrib tutorials https://docs.opencv.org/master/d3/d81... ) The first image created is pretty much always 70% black on the left, and 30% white and then it iterates in a kind of offset way from there

then when it is getting down to the single pixels, there tends to be a double to quadruple width stripe present

attached are some images showing what happens

i can run the full process by the way, and decode these pictures, but they don't seem to come out correct at all, usually just a blank screen instead of a depth map.

EDIT: i couldn't get pics to upload to this post, so here is a link to example pics of the graycode bugs from Image 0, and image 22 https://photos.app.goo.gl/3PEwaLshXtZ...

Update:

I took a look at the Graycode code, and noticed the default value was 1024x768 ( got one pic to upload somehow! is there a 1Mb limit on photos?) So i tried that value, and surprisingly the first set of graycode looks correct now (even though my monitor is 1920x1080)

BUT the second set of graycode (horizontal lines) are still way offset

image description

image description

If i set the resolution for the graycode to generate to 1024 x 1024, i get what looks like proper graycode in the vertical and horizontal direction!

But if i do 1920x1920 it is all skewed again

but if i do 2048 x 2048 everything is even.

Is something messed up with the math they are using to divide up the pixels when generating the graycode pattern? https://github.com/opencv/opencv_cont...

is it supposed to be skewed at resolutions that aren't powers of 2?

edit retag flag offensive close merge delete

Comments

In edit ..click image icon to up;load image.

supra56 gravatar imagesupra56 ( 2020-03-24 07:37:36 -0600 )edit

Yeah tried that, it was never going through :/

blorgggg gravatar imageblorgggg ( 2020-03-25 19:22:39 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2020-03-26 01:46:30 -0600

blorgggg gravatar image

updated 2020-03-26 01:48:26 -0600

So after trying powers of two resolutions, and getting the same results when passing it through the graycode decode function in this module, my main conclusion is just that when working with non-powers of 2 sized resolutions, the resulting graycode must have some weird offset. And that it wouldn't really matter as long as the decoding process is consistently offset as well.

So the possible answer to my question above is, yes, the graycode is supposed to be that way.

(but i still don't get the small doubled up lines that appear in the later images in the set of the graycode)

(andy my real question now is how come my decode still doesn't give a depth map that looks like anything the camera is facing) :( image description

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-03-23 12:48:43 -0600

Seen: 240 times

Last updated: Mar 26 '20