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

Method FindBrightestPointInRow

ScanThread.cpp:294–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294float ScanThread::FindBrightestPointInRow(BwImage subPx, int row, int rowWidth)
295{
296 // init values we will use
297 int laserSum, laserNum, laserCenter, maxPx, maxPxVal;
298
299 int h = row;
300
301 // for each row, find the location of the laser
302 laserSum = 0;
303 laserNum = 0;
304 maxPx = -1;
305 maxPxVal = -1;
306
307 for (int w = 0; w < rowWidth; w++)
308 {
309 // for each row of pixels, find the brightest point on the laser beam
310
311 // for every pixel in the image, check to see if it is non-zero and thus corresponding
312 // to a pixel that is illuminated by the laser
313
314 if (subPx[h][w] > maxPxVal && subPx[h][w] > minPxVal)
315 {
316 // this point is the brightest we have seen so far and it exceeds our minimum value
317 maxPxVal = subPx[h][w];
318 maxPx = w;
319
320 laserSum = w;
321 laserNum = 1;
322
323 } else if (subPx[h][w] == maxPxVal)
324 {
325 // this point is exactly as bright as our current brightest pixel, so average them
326 laserSum += w;
327 laserNum ++;
328 }
329 }
330
331 // we are done with this row -- select the most likely point.
332
333 // TODO: subpixel interpolation
334
335
336 if (maxPx >= 0)
337 {
338 // compute the center point of the laser
339 laserCenter = laserSum/laserNum;
340 } else {
341 // no value for this row
342 laserCenter = 0;
343 }
344 return laserCenter;
345}
346
347// Compute where the 3d points are based on where the laser was detected in the image
348void ScanThread::AddPointcloudPoints(vector<float> *laserPos)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected