Browse Source

Improve video reception quality

pull/48/head
Tux3 / Mlkj / !Lev.uXFMLA 11 years ago
parent
commit
f7dcb1712d
  1. 6
      widget/camera.cpp
  2. 8
      widget/netcamview.cpp

6
widget/camera.cpp

@ -132,7 +132,11 @@ bool Camera::isFormatSupported(const QVideoSurfaceFormat& format) const @@ -132,7 +132,11 @@ bool Camera::isFormatSupported(const QVideoSurfaceFormat& format) const
QImage Camera::getLastImage()
{
lastFrame.map(QAbstractVideoBuffer::ReadOnly);
if (!lastFrame.map(QAbstractVideoBuffer::ReadOnly))
{
qWarning() << "Camera::getLastImage: Error maping last frame";
return QImage();
}
int w = lastFrame.width(), h = lastFrame.height();
int bpl = lastFrame.bytesPerLine(), cxbpl = bpl/2;
QImage img(w, h, QImage::Format_RGB32);

8
widget/netcamview.cpp

@ -20,16 +20,16 @@ void NetCamView::updateDisplay(vpx_image frame) @@ -20,16 +20,16 @@ void NetCamView::updateDisplay(vpx_image frame)
QImage img(w, h, QImage::Format_RGB32);
uint8_t* yData = frame.planes[VPX_PLANE_Y];
uint8_t* uData = frame.planes[VPX_PLANE_V];
uint8_t* vData = frame.planes[VPX_PLANE_U];
uint8_t* uData = frame.planes[VPX_PLANE_U];
uint8_t* vData = frame.planes[VPX_PLANE_V];
for (int i = 0; i< h; i++)
{
uint32_t* scanline = (uint32_t*)img.scanLine(i);
for (int j=0; j < w; j++)
{
float Y = yData[i*bpl + j];
float U = uData[i*cxbpl/2 + j/2];
float V = vData[i*cxbpl/2 + j/2];
float U = uData[i/2*cxbpl + j/2];
float V = vData[i/2*cxbpl + j/2];
uint8_t R = qMax(qMin((int)(Y + 1.402 * (V - 128)),255),0);
uint8_t G = qMax(qMin((int)(Y - 0.344 * (U - 128) - 0.714 * (V - 128)),255),0);

Loading…
Cancel
Save