MCPcopy Create free account
hub / github.com/andybarry/makerscanner / AddPointcloudPoints

Method AddPointcloudPoints

ScanThread.cpp:348–416  ·  view source on GitHub ↗

Compute where the 3d points are based on where the laser was detected in the image

Source from the content-addressed store, hash-verified

346
347// Compute where the 3d points are based on where the laser was detected in the image
348void ScanThread::AddPointcloudPoints(vector<float> *laserPos)
349{
350 // compute distance for this pixel
351 // calculate phi from camera parameters and Y pixel location
352 // (assume dimensions of noLaser are the same as all other images)
353
354 float widthReference = GetReferenceLaserLocation(laserPos);
355
356 if (widthReference < 0)
357 {
358 // we don't know where the refernce laser is -- abort
359 return;
360 }
361
362 float laserCenter;
363
364 int r, g, b;
365 double pxDist, theta, phi;
366
367 // set up single-pixel access to the subtracted and original image
368 RgbImage noLaserPx(noLaser);
369 int h = 0;
370 for (h=0;h<int(laserPos->size());h++)
371 {
372 laserCenter = (*laserPos)[h];
373
374 // check to make sure that we have data for this row
375 if (laserCenter >= 0)
376 {
377
378 phi = (noLaser->height/2 - h) * double(CAMERA_Y_MAX - CAMERA_Y_MIN)/double(noLaser->height);
379
380 // convert to radians
381 phi = phi * 3.14159 / 180.0;
382
383 pxDist = PixelToDistance2(laserCenter, widthReference);
384
385 if (pxDist < 0)
386 {
387 // not a valid point
388 return;
389 }
390
391
392 // compute theta based on laserCenter
393 theta = (laserCenter - noLaser->width/2) * double(CAMERA_X_MAX - CAMERA_X_MIN)/double(noLaser->width);
394
395 // convert to radians
396 theta = theta * 3.14159 / 180.0;
397
398 r = noLaserPx[h][int(laserCenter + 0.5)].r;
399 g = noLaserPx[h][int(laserCenter + 0.5)].g;
400 b = noLaserPx[h][int(laserCenter + 0.5)].b;
401
402// if (h == 100)
403// {
404// wxString tmp = wxT("\ndiff: ");
405// tmp << widthReference - laserCenter;

Callers

nothing calls this directly

Calls 1

AddPointMethod · 0.80

Tested by

no test coverage detected