QCamera is not working in N950?
-
Hi guys,
I am trying to use QCamera on N950 and capture frames using QVideoSurface, but without any results.
the screen appears black and i got this on the applicationoutput screen
@Using the meego graphics system
"org.freedesktop.DBus.Error.AccessDenied" "Rejected send message, 3 matched rules; type="method_call", sender=":1.432" (uid=29999 pid=7842 comm="/opt/CameraSample/bin/CameraSample ") interface="com.nokia.mce.request" member="req_tklock_mode_change" error name="(unset)" requested_reply=0 destination="com.nokia.mce" (uid=0 pid=529 comm="/sbin/mce --force-syslog "))"virtual GstElement* QGstreamerGLTextureRenderer::videoSink() : Fallback to QVideoSurfaceGstSink since EGLImageTextureHandle is not supported
ResourceSet::executeNextRequest().
ResourceSet::executeNextRequest()...the completed request is not present.
CameraBin error: "Could not negotiate format"
"org.freedesktop.DBus.Error.AccessDenied" "Rejected send message, 3 matched rules; type="method_call", sender=":1.432" (uid=29999 pid=7842 comm="/opt/CameraSample/bin/CameraSample ") interface="com.nokia.mce.request" member="req_tklock_mode_change" error name="(unset)" requested_reply=0 destination="com.nokia.mce" (uid=0 pid=529 comm="/sbin/mce --force-syslog "))" @you can find the complete project "here":http://dl.dropbox.com/u/10705622/CameraSample.zip
-
which Qt SDK , are you using ?
It should support Qt Mobility 1.2, in Qt SDK 1.1.3.
-
I am using Qt SDK 1.1.3
-
Have you seen http://developer.qt.nokia.com/forums/viewthread/8375/ yet? It may contain some useful information for your problem.
-
Hi chriadam,
I tried to set the format to
@QVideoFrame::Format_UYVY@
but i always get the following error
Failed to start video surface
CameraBin error: "Internal data flow error."here are my code
@#include "videosurface.h"
#include <QPainter>#define DEBUG_INFO
VideoSurface::VideoSurface(QWidget* widget, VideoIF* target, QObject* parent)
: QAbstractVideoSurface(parent)
{
m_targetWidget = widget;
m_target = target;
m_imageFormat = QImage::Format_Invalid;
orientationSensor=new QOrientationSensor();
m_orientation = ORIENTATION_LANDSCAPE;
orientationSensor->start();
}VideoSurface::~VideoSurface()
{
orientationSensor->stop();delete orientationSensor;
}
bool VideoSurface::start(const QVideoSurfaceFormat &format)
{
m_videoFormat = format;
const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat());
const QSize size = format.frameSize();if (imageFormat != QImage::Format_Invalid && !size.isEmpty()) { m_imageFormat = imageFormat; QAbstractVideoSurface::start(format); return true; } else { return false; }
}
unsigned char* VideoSurface::createGrayscaleBuffer(const QImage &dstImage, const int dWidth, const int dHeight)const
{
unsigned char* grayscaledBuffer = new unsigned char [dWidth*dHeight];
int offset = 0;
// default QT grayscale
for(int y = 0; y< dHeight; y++)
for(int x = 0; x< dWidth; x++)
grayscaledBuffer[offset++]=qGray(dstImage.pixel(x,y));return grayscaledBuffer;
}
bool VideoSurface::present(const QVideoFrame &frame)
{
m_frame = frame;// number of frames received for display numFrames++; if (surfaceFormat().pixelFormat() != m_frame.pixelFormat() || surfaceFormat().frameSize() != m_frame.size()) { stop(); return false; } else { m_frame.map(QAbstractVideoBuffer::ReadOnly); iWidth = m_frame.width(); iHeight = m_frame.height(); int line = m_frame.bytesPerLine(); // build QImage from frame m_completeImage = QImage(m_frame.bits(), iWidth, iHeight, line, m_frame.imageFormatFromPixelFormat(m_frame.pixelFormat())); m_frame.unmap(); QImage dstImage = scaleImage(m_completeImage); int dHeight = dstImage.height(); int dWidth = dstImage.width(); unsigned char* grayscaledBuffer = createGrayscaleBuffer(dstImage, dWidth, dHeight); m_orientation = ORIENTATION_CCW; QOrientationReading* reading= orientationSensor->reading(); if ( orientationSensor->isActive() ){ if (reading->orientation() == QOrientationReading::RightUp){ //rotate with -90 (ccw) m_orientation = ORIENTATION_LANDSCAPE; } } // do some image processing work ////////////// delete grayscaledBuffer; // convert points back to original size double iWi = (double)iWidth/dWidth; double iHi = (double)iHeight/dHeight; // should keep aspect ratio iWi = iHi = qMin(iWi, iHi); // enlarge faces int marginX, marginY; m_target->updateVideo(); return true; }
}
QImage VideoSurface::scaleImage(const QImage & srcImage)const
{
QImage dstImage;
if(MAX_DIM < iWidth || MAX_DIM < iHeight){
if(iWidth > iHeight)
dstImage = srcImage.scaledToWidth(MAX_DIM, Qt::SmoothTransformation);
else
dstImage = srcImage.scaledToHeight(MAX_DIM, Qt::SmoothTransformation);
}
else
dstImage = srcImage;
return dstImage;
}void VideoSurface::paint(QPainter *painter)
{
if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) {
QImage image(
m_frame.bits(),
m_frame.width(),
m_frame.height(),
m_frame.bytesPerLine(),
m_imageFormat);
QRect r = m_targetWidget->rect();int shiftX = qAbs(r.size().width() - image.size().width()) / 2; int shiftY = qAbs(r.size().height() - image.size().height()) / 2; QPoint centerPic(shiftX , shiftY); if (!image.isNull()) { painter->drawImage(centerPic,image); // draw faces } m_frame.unmap(); }
}
QListQVideoFrame::PixelFormat VideoSurface::supportedPixelFormats(
QAbstractVideoBuffer::HandleType handleType) const
{
if (handleType == QAbstractVideoBuffer::NoHandle) {
return QListQVideoFrame::PixelFormat()
// << QVideoFrame::Format_RGB32
// << QVideoFrame::Format_ARGB32
// << QVideoFrame::Format_ARGB32_Premultiplied
// << QVideoFrame::Format_RGB565
// << QVideoFrame::Format_RGB555;
<<QVideoFrame::Format_UYVY;
} else {
return QListQVideoFrame::PixelFormat();
}
}@
Thank you for your help
-
I am having same (Failed to start video surface / CameraBin error: “Internal data flow error.” ) problem on N9. So help would be appreciated. Did you already solve this?
-
I am still not able to do this, also nokia support are not able to find a work around for this bug.
-
Have everyone solved it?
-
No, I removed this feature from my application.
but there are many updates and bug fixes ,see it may be fixed. -
http://www.developer.nokia.com/Community/Wiki/MeeGo_Camera_VideoSurface_manipulation
has a working example.