Commit 5ed4a219 authored by Thiago Santini's avatar Thiago Santini

YUV support improvements

parent 22897a30
......@@ -96,6 +96,7 @@ QCameraViewfinderSettings Camera::getViewfinderSettings(const QCameraInfo camera
if ( setting.pixelFormat() == QVideoFrame::Format_RGB32
|| setting.pixelFormat() == QVideoFrame::Format_RGB24
|| setting.pixelFormat() == QVideoFrame::Format_YUYV
|| setting.pixelFormat() == QVideoFrame::Format_UYVY
|| setting.pixelFormat() == QVideoFrame::Format_Jpeg ) {
if (recommended.isNull())
......
......@@ -3,7 +3,7 @@
using namespace cv;
DataRecorder::DataRecorder(QString id, QString header, QObject *parent)
: id(id),
: id(id.replace("Widget", "").replace(" ", "")),
header(header),
videoWriter(NULL),
dataFile(NULL),
......
......@@ -115,7 +115,7 @@ bool FrameGrabber::present(const QVideoFrame &frame)
success = yuyv_2bmp(copy, cvFrame);
break;
default:
qDebug() << "Unknown pixel format:" << frame.pixelFormat();
qWarning() << "Unknown pixel format:" << frame.pixelFormat();
break;
}
copy.unmap();
......@@ -196,26 +196,12 @@ bool FrameGrabber::rgb32_2bmp(const QVideoFrame &in, cv::Mat &cvFrame)
bool FrameGrabber::yuyv_2bmp(const QVideoFrame &in, cv::Mat &cvFrame)
{
// TODO: can we optimize this?
cvFrame = Mat(abs(in.height()), abs(in.width()), CV_8UC3);
const unsigned char *pyuv = in.bits();
unsigned char *pbgr = cvFrame.data;
for(int i = 0; i < in.mappedBytes(); i += 4) {
int b = (0x7179 * ((pyuv)[1] - 0x80)) >> 0xE;
int g = (-0x1604 * ((pyuv)[1] - 0x80) - 0x2DB2 * ((pyuv)[3] - 0x80)) >> 0xE;
int r = (0x59CB * ((pyuv)[3] - 0x80)) >> 0xE;
(pbgr)[0] = (*(pyuv) + b);
(pbgr)[1] = (*(pyuv) + g);
(pbgr)[2] = (*(pyuv) + r);
(pbgr)[3] = ((pyuv)[2] + b);
(pbgr)[4] = ((pyuv)[2] + g);
(pbgr)[5] = ((pyuv)[2] + r);
pbgr += 6;
pyuv += 4;
}
if (code != CV_8UC3)
cvtColor(cvFrame, cvFrame, CV_BGR2GRAY);
Mat yuyv = Mat(abs(in.height()), abs(in.width()), CV_8UC2, (void*) in.bits());
if (code == CV_8UC3)
cvtColor(yuyv, cvFrame, CV_YUV2BGR_YUYV);
else
cvtColor(yuyv, cvFrame, CV_YUV2GRAY_YUYV);
return true;
}
//TODO: add support for other frame formats
......@@ -81,9 +81,9 @@ public:
gazeEstimationMethod("POLY_X_Y_XY_XX_YY_XYY_YXX_XXYY"),
visualize(true),
visualizationTimeS(5),
minCentralAreaCoverage(0.8f),
minPeriphericAreaCoverage(0.1f),
maxReprojectionError(4.f)
minCentralAreaCoverage(0.0f),
minPeriphericAreaCoverage(0.0f),
maxReprojectionError(10.0f)
{}
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment