Hi,
Environment: Mac mini, MacOS M1 64bit, Monterey 12.3.1
USB port: USB 3.0
Camera format: MotionJPEG
Description:
My camera format is MotionJPEG, and my camera can live play, but I found decoding camera format MotionJPEG to NV12 is sometimes failed. Please refer the attached files.
//********************
C++ code:
void CPreviewPage::startVideoStreaming(void)
{
QString str_id;
QString str_vid;
QString str_pid;
const QList<QCameraDevice> cameras = QMediaDevices::videoInputs();
for (const QCameraDevice &camera_device : cameras)
{
// example id = "0x2600000a16809b0" or "0x100000a1680970"
//qDebug() << "camera_device.id = " << camera_device.id();
str_id = camera_device.id().right(8);
str_vid = str_id.mid(0,4);
str_pid = str_id.right(4);
qDebug() << "id = " << str_id; qDebug() << "vid = 0x" << str_vid; qDebug() << "pid = 0x" << str_pid; if(str_vid != "a168") continue; captureSession = new QMediaCaptureSession(this); pCamera = new QCamera(camera_device); captureSession->setCamera(pCamera); pGraphyScene = new QGraphicsScene(0,0,640,480); //pGraphyView = new QGraphicsView(this); pGraphyView->setScene(pGraphyScene); pGraphyVideoItem = new QGraphicsVideoItem; pGraphyVideoItem->setSize(QSizeF(640,480)); pGraphyVideoItem->setPos(0,0); pGraphyScene->addItem(pGraphyVideoItem); captureSession->setVideoOutput(pGraphyVideoItem); pImageCapture = new QImageCapture((QObject*)pCamera); captureSession->setImageCapture(pImageCapture); //QObject::connect(pImageCapture, SIGNAL(imageAvailable(int, const QVideoFrame&)), this, SLOT(onCaptureVideoFrame(int, const QVideoFrame&))); QObject::connect(pImageCapture, SIGNAL(imageCaptured(int, const QImage&)), this, SLOT(onCaptureImage(int, const QImage&))); pCamera->start(); // live play. QString title = camera_device.description() + " 0x" + QString::number(myDeviceDetectionData.devicePid, 16); setWindowTitle(title); break; }
}