@@ -96,6 +96,8 @@ void V4L2Grabber::setSignalThreshold(double redSignalThreshold, double greenSign
96
96
_noSignalThresholdColor.green = uint8_t (255 *greenSignalThreshold);
97
97
_noSignalThresholdColor.blue = uint8_t (255 *blueSignalThreshold);
98
98
_noSignalCounterThreshold = std::max (1 , noSignalCounterThreshold);
99
+
100
+ std::cout << " V4L2 grabber signal threshold set to: " << _noSignalThresholdColor << std::endl;
99
101
}
100
102
101
103
void V4L2Grabber::start ()
@@ -674,8 +676,6 @@ void V4L2Grabber::process_image(const uint8_t * data)
674
676
int outputHeight = (height - _cropTop - _cropBottom + _verticalPixelDecimation/2 ) / _verticalPixelDecimation;
675
677
Image<ColorRgb> image (outputWidth, outputHeight);
676
678
677
- bool noSignal = true ;
678
-
679
679
for (int ySource = _cropTop + _verticalPixelDecimation/2 , yDest = 0 ; ySource < height - _cropBottom; ySource += _verticalPixelDecimation, ++yDest)
680
680
{
681
681
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)
701
701
702
702
ColorRgb & rgb = image (xDest, yDest);
703
703
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);
704
718
noSignal &= rgb <= _noSignalThresholdColor;
705
719
}
706
720
}
0 commit comments