Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit f0c1920

Browse files
committed
Only use center of V4L2 grabbed image to determine if there is a signal to allow some noise at the borders
1 parent 4c04035 commit f0c1920

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

libsrc/grabber/v4l2/V4L2Grabber.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ void V4L2Grabber::setSignalThreshold(double redSignalThreshold, double greenSign
9696
_noSignalThresholdColor.green = uint8_t(255*greenSignalThreshold);
9797
_noSignalThresholdColor.blue = uint8_t(255*blueSignalThreshold);
9898
_noSignalCounterThreshold = std::max(1, noSignalCounterThreshold);
99+
100+
std::cout << "V4L2 grabber signal threshold set to: " << _noSignalThresholdColor << std::endl;
99101
}
100102

101103
void V4L2Grabber::start()
@@ -674,8 +676,6 @@ void V4L2Grabber::process_image(const uint8_t * data)
674676
int outputHeight = (height - _cropTop - _cropBottom + _verticalPixelDecimation/2) / _verticalPixelDecimation;
675677
Image<ColorRgb> image(outputWidth, outputHeight);
676678

677-
bool noSignal = true;
678-
679679
for (int ySource = _cropTop + _verticalPixelDecimation/2, yDest = 0; ySource < height - _cropBottom; ySource += _verticalPixelDecimation, ++yDest)
680680
{
681681
for (int xSource = _cropLeft + _horizontalPixelDecimation/2, xDest = 0; xSource < width - _cropRight; xSource += _horizontalPixelDecimation, ++xDest)
@@ -701,6 +701,20 @@ void V4L2Grabber::process_image(const uint8_t * data)
701701

702702
ColorRgb & rgb = image(xDest, yDest);
703703
yuv2rgb(y, u, v, rgb.red, rgb.green, rgb.blue);
704+
}
705+
}
706+
707+
// check signal (only in center of the resulting image, because some grabbers have noise values along the borders)
708+
bool noSignal = true;
709+
for (unsigned x = 0; noSignal && x < (image.width()>>1); ++x)
710+
{
711+
int xImage = (image.width()>>2) + x;
712+
713+
for (unsigned y = 0; noSignal && y < (image.height()>>1); ++y)
714+
{
715+
int yImage = (image.height()>>2) + y;
716+
717+
ColorRgb & rgb = image(xImage, yImage);
704718
noSignal &= rgb <= _noSignalThresholdColor;
705719
}
706720
}

0 commit comments

Comments
 (0)