Fixed capturing rectangle to be respected when decoding YUYV images in QZXingFilter. Now it seems that Decoding is working for Linux. #86

This commit is contained in:
Nikos Ftylitakis 2019-04-17 10:38:55 +03:00
parent b952523aeb
commit 4f37a03731
1 changed files with 3 additions and 6 deletions

View File

@ -289,9 +289,9 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame
pixel = image_ptr->bits(); pixel = image_ptr->bits();
for (int y = captureRect.startY; y < captureRect.endY; y++){ for (int y = captureRect.startY; y < captureRect.endY; y++){
const uint32_t *row = &yuvPtr[y*(width/2)-(width/4)]; const uint32_t *row = &yuvPtr[y*(width/2)];
int end = captureRect.startX + (captureRect.endX - captureRect.startX)/2; int end = captureRect.startX/2 + (captureRect.endX - captureRect.startX)/2;
for (int x = captureRect.startX; x < end; x++){ for (int x = captureRect.startX/2; x < end; x++){
const uint8_t *pxl = reinterpret_cast<const uint8_t *>(&row[x]); const uint8_t *pxl = reinterpret_cast<const uint8_t *>(&row[x]);
const uint8_t y0 = pxl[0]; const uint8_t y0 = pxl[0];
const uint8_t u = pxl[1]; const uint8_t u = pxl[1];
@ -323,7 +323,6 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame
return; return;
} }
// image_ptr->save("/home/ftylitak/tempimage-no-crop.png");
if (captureRect.isValid && image_ptr->size() != _captureRect.size()) if (captureRect.isValid && image_ptr->size() != _captureRect.size())
image_ptr = new QImage(image_ptr->copy(_captureRect)); image_ptr = new QImage(image_ptr->copy(_captureRect));
@ -335,8 +334,6 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame
//QZXingImageProvider::getInstance()->storeImage(image); //QZXingImageProvider::getInstance()->storeImage(image);
image_ptr->save("/home/ftylitak/tempimage.png");
decode(*image_ptr); decode(*image_ptr);
delete image_ptr; delete image_ptr;