Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Structured Light - How to do when the projector's resolution is lower than patterns?

I try to build a structured light environment to do 3D scanning.

As far as I know, if I choose to use gray code to reconstruct a 3D model, I have to implement specific patterns that were encode in power 2(2^x, x = 0 ~ 10).

enter image description here

That is said, the patterns must be at least 1024 x 1024 in resolution.

What if my DLP projector only support resolution up to 800 x 480? It projects Moire pattern when the gray code pattern resolution becomes too high(I tried). What should I do?

My friends suggest that I create 1024 x 1024 patterns, and "crop" them into 800 x 480,

but I thought the gray code should follow specific sequence and patterns, my friends suggestion will create several image that is not symmetry.

Does anyone have the same experience like me?

----------2015.8.4 Update Question----------

I was thinking that if my projector can't perfectly projects high resolution patterns, can I just let it projects the patterns with low resolution, for instance, from 2^0 to 2^6?

Or the gray code strictly demands patterns from 2^0 to 2^10? Otherwise gray code is not available?

like image 961
APU Avatar asked Aug 03 '15 07:08

APU


1 Answers

you can not directly scale down to your resolution

because it would distort the pattern make it useless

instead you can:

  1. crop it to your resolution

    but you need to handle that in the scanning part too because you would not have the full pattern available

  2. use nearest usable power of 2 resolution

    like 512x256 and create pattern for it. The rest of the space is unused (wasting pixels) 512x256

  3. use bullet #2 + scale up to fit your resolution better

    so create pattern 512x256 and linearly scale to fit to 800x480 as much as you can so:

    800/512 = 1.5625
    480/256 = 1.8750
    

    use the smaller scale (512x256 * 1.5625 -> 800x400) so scale the pattern by 1.5625 and use that as a pattern image

    800x400

    this is scaled by nearest neighbor to avoid subpixel grayscale colors which are harder to detect. This will waste less pixels but it can lower the precision of 3D scan !!!

This is how I generate my pattern in C++ and VCL:

// [generate pattern xs*ys power of 2 resolution]
// clear buffer
bmp->Canvas->Brush->Color=clBlack;
bmp->Canvas->FillRect(TRect(0,0,xs,ys));
int x,y,a,da;
for (da=0;1<<da<xs;da++);                   // number of bits per x resolution
for (a=0,y=0;y<ys;y++,a=(y*da)/ys)
 for (x=0;x<xs;x++)
  if (int((x>>a)&1)==0) pyx[ys-1-y][x]=0x00FFFFFF;
bmp->SaveToFile("3D_scann_pattern0.bmp");
  • bmp is VCL bitmap
  • xs,ys is the resolution of a bitmap
  • p[ys][xs] is direct 32bit pixel access to bitmap

This is slight differently encoded then your pattern !!!

[Notes]

  • If you need precision use bullet #2
  • If you need to cover bigger area use bullet #3
  • You can also scale in y axis differently then in x axis as this is just 1D encoding
like image 166
Spektre Avatar answered Oct 01 '22 00:10

Spektre