Solved QCamera is not working with CMOS-MIPI-OV5640
-
Hi,
I am having iMX6 development kit with CMOS-MIPI-OV5640. Kit is having Debian Stretch 9.5.
At present, I am trying to play live stream using QT (QCamera functionality). I have developed sample code for that and it is working fine with laptop(ubuntu 16.04) and it's webcam.
But on IMX6 development kit, on the execution of QCamera->start(), the QT application hangs.Please find code related to camera:
QCamera *pCamera;
//Find Camera
QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
foreach (const QCameraInfo &cameraInfo, cameras){
pCamera = new QCamera(cameraInfo, this); //gives cameraInfo.deviceName() = "/dev/video0"
}
pCameraViewfinder = new QCameraViewfinder(this);
pCameraImageCapture = new QCameraImageCapture(pCamera, this);
pVBoxLayout = new QVBoxLayout();//Set Camera View
pCamera->setViewfinder(pCameraViewfinder);
pVBoxLayout->addWidget(pCameraViewfinder);
ui->scrollArea->setLayout(pVBoxLayout);// Start Camera
pCamera->setCaptureMode(QCamera::CaptureVideo);
pCamera→start(); //Hangs at this line, not able to do anything on UI and gives an error.Looking forward to hearing.
Thank You,
Nikita Panchal -
Hi and welcome to devnet,
Can you access that camera properly from gstreamer ?
-
Yes.
I am able to get live stream with :
gst-launch-1.0 imxv4l2videosrc device=/dev/video0 ! imxeglvivsink -
Do you have any error printed on the command line when running your Qt application ?
-
Hi Devent,
First of thank you for looking into it.
Qt application itself doesn't print any error on console.While analyze the problem I identified two things as below:
-
Difference between Camera Start method on laptop and IMX6.
On laptop: pCamera->start() followes status: LoadingStatus -> LoadedStatus -> StartingStatus -> ActiveStatus.
On IMX6 : pCamera->start() followes status: LoadingStatus
So, It is stuck to change status from "LoadingStatus" to "LoadedStatus". -
I got below error with dmesg command:
pid: 1170
uid: [ 1001]
tgid: 1170
total_vm:220354
rss: 150081
nr_ptes: 405
nr_pmds: 0
swapents: 0
oom_score_adj: 0
name: CameraStartApp
Out of memory: Kill process 1170 (CameraStartApp) score 587 or sacrifice child
Killed process 1170 (CameraStartApp) total-vm:881416kB, anon-rss:599680kB, file-rss:0kB, shmem-rss:644kB
-
-
Looks like a device specific source
@nikita.panchal09 said in QCamera is not working with CMOS-MIPI-OV5640:
imxv4l2videosrc
You should consider modifying the gstreamer plugin to use that one in place of the
camerabin
it currently uses. -
Hi,
Thank you for your answer.
Actually, I am new to GStreamer and qtmultimedia. I would be grateful, if you can provide steps or related website-link to do these things.Meanwhile, I found the hardcoded value of camera source as "v4l2src" in below files from QT source. Do these both files requires to change to "imxv4l2videosrc" from "v4l2src" and build it again?
- qtmultimedia-5.12/src/plugins/gstreamer/mediacapture/qgstreamerv4l2input.cpp:70: GstElement *camera = gst_element_factory_make("v4l2src", "camera_source");
- qtmultimedia-5.12/src/plugins/gstreamer/camerabin/camerabinsession.cpp:542: m_videoSrc = gst_element_factory_make("v4l2src", "camera_source");
Thanks.
-
That's what I would try first yes. No need to rebuild all of Qt. Only the GStreamer plugin.
-
Hi,
I followed below steps:
- Downloaded qt-multimedia
- Edited mentioned files with "imxv4l2videosrc"
- Compiled and Installed.
It works...! I am able to start the camera.
Thank you
-
Hi,
Currently, I am trying to record video on IMX6(Debian Stretch 9.5). I am using QT multimediawidget "camera" example (Using QCamera and QMediaRecorder).
The problem is, On record start (recorder->record) the camera output is slowed down extremely. and after approximate 15 seconds, It gives below error and streaming gets stopped.
"CameraBin error: "Internal data stream error."I am able to record video with gstreamer using below command and it works fine.
gst-launch-1.0 imxv4l2videosrc device=/dev/video0 imx-capture-mode=5 fps-n=30 ! queue ! imxvpuenc_h264 bitrate=10000 ! avimux ! filesink location=test.aviLooking forward to hearing.
Thank You.
-
From the looks of it,
imxvpuenc_h264
is likely optimised for your device. I would go check theqgstreamercapturesession.cpp
content to see how to possibly modify the pipeline to use that encoder. -
Hi,
Thanks for your answer.
While analyzing the problem I found below things as per below:
- In the computer, it saves video file as .mkv and in the board, It saves as .ogg
- After camera record start it gives error as "CameraBin error: "Internal data stream error."
simultaneously on the console, I am getting "ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0" error. - As per your saying I have to write codec "imxvpuenc_h264". But I am confused that where to change it.
I have changed "x264enc" to "imxvpuenc_h264" in file qgstreamervideoencode.cpp. But, while recording It is not executing.
Thanks,
Nikita Panchal -
What do you mean by "not executing" ?
-
I have put "qDebug()" on it. It doesn't print on recording start.
-
Maybe a silly question but are you sure you replaced the plugin once you built it ?
-
Hi,
I have applied "0001-QCamera-can-t-set-recording-container-format-video-a.patch" patch from below link and it works for me.
"https://community.nxp.com/docs/DOC-330047"
Thanks for your support.