Qt_Camera crash on Jetson Nano
-
@SGaist ,
Further I have modified code a little bit and make sure the code has implemented in asynchronous , I didn't see the earlier warning message "CameraBin warning: "Resource busy or not available."", but still I am seeing the same segfault issue.
Please help me to resolve thiis issue
Here is the Gstreamer debug messages:
available for media type: application/x-gst-av-webp
77 0:00:00.067371505 19108 0x3da392d0 WARN default descriptions.c:1229:gst_pb_utils_get_codec_description: No description available for media type: application/x-gst-av-wtv
78 0:00:00.067440256 19108 0x3da392d0 WARN default descriptions.c:743:format_info_get_desc: Unexpected MPEG-1 layer in au dio/mpeg, mpegversion=(int)1
79 0:00:00.136766277 19108 0x3da392d0 WARN GST_ELEMENT_FACTORY gstelementfactory.c:456:gst_element_factory_make: no such element fact ory "vaapisink"!
80 0:00:00.142514305 19108 0x3da392d0 WARN GST_ELEMENT_FACTORY gstelementfactory.c:456:gst_element_factory_make: no such element fact ory "vaapisink"!
81 "/dev/video0"
82 mythread
83 0:00:00.528898667 19108 0x3df0cb20 FIXME default gstutils.c:3981:gst_pad_create_stream_id_internal:preview-appsrc:src Creating random stream-id, consider implementing a deterministic way of creating a stream-id
84 mythread
85 mythread
86 onValueChanged
Segmentation fault (core dumped)Thanks in Advance,
-
Can you run your application through the debugger and show the back trace ?
In any case, your use of synchronisation primitive and threading is just adding complexity for nothing and adds another layer of issues.
-
Hi @SGaist ,
Somehow I was failed to run remote machine using qt-creator and I didn't get the back trace.
When I run application using gdb on target platform I got only above call stack which I mentioned below as well.backtrace:
Thread 10 "queue5:src" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fa8cce130 (LWP 14841)]
0x0000007fb01f8cbc in gst_memory_unmap () from /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
(gdb) bt
#0 0x0000007fb01f8cbc in gst_memory_unmap () at /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
#1 0x0000007fa98df0b8 in () at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvjpeg.so
#2 0x0000000000a15550 in ()
(gdb)Also I have notice another issue, when I configure the QCameraImageCapture as a CaptureToBuffer, why this capture evening saving the image(.jpg) file on to disk location(Pictures folder ).
To check further I put some prints and its showing expected output .
qDebug() << m_imageCapture->isCaptureDestinationSupported(QCameraImageCapture::CaptureToFile);
qDebug() << m_imageCapture->isCaptureDestinationSupported(QCameraImageCapture::CaptureToBuffer);
m_imageCapture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
qDebug() << m_imageCapture->captureDestination();true
true
QFlags(0x2)Kindly help me why jpg files are saving and how to stop it?
Thanks, in advance,
-
Hi @SGaist ,
Thanks for you quick reply on this issue .
Here is my observations please kindly check.
Suggested example is working fine on x86 machine, but it comes to hardware platform I still see a segfault and first frame itself the application crash.
Thread 11 "queue5:src" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fa8d74130 (LWP 16081)]
0x0000007fb0170cbc in gst_memory_unmap () from /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
(gdb) bt
#0 0x0000007fb0170cbc in gst_memory_unmap () at /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
#1 0x0000007fa98dc0b8 in () at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvjpeg.so
#2 0x0000000000a13910 in ()Example:
mainwindow.cpp:
#include "ui_mainwindow.h"
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);QCamera *cam = new QCamera; cam->setCaptureMode(QCamera::CaptureStillImage); QCameraViewfinder *viewfinder = new QCameraViewfinder; viewfinder->show(); QCameraImageCapture *cap = new QCameraImageCapture(cam); cap->setCaptureDestination(QCameraImageCapture::CaptureToBuffer); cam->setViewfinder(viewfinder); QObject::connect(cap, &QCameraImageCapture::imageCaptured, [=] (int id, QImage img) { QByteArray buf; QBuffer buffer(&buf); buffer.open(QIODevice::WriteOnly); img.save(&buffer, "PNG"); }); QObject::connect(cap, &QCameraImageCapture::readyForCaptureChanged, [=] (bool state) { if(state == true) { cam->searchAndLock(); cap->capture(); cam->unlock(); } }); cam->start();
}
MainWindow::~MainWindow()
{
delete ui;
}main.cpp:
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
//w.show();
return a.exec();
} -
Which Linux distribution are your running on your target ?
-
Hi @SGaist ,
I am not sure how to get that details, but from dmesg command I could see below message
Here is my Linux details ,
Linux version 4.9.140-tegra (buildbrain@mobile-u64-2713) (gcc version 7.3.1 20180425 [linaro-7.3-2018.05 revision d29120a424ecfbc167ef90065c0eeb7f91977701] (Linaro GCC 7.3-2018.05) ) #1 SMP PREEMPT Mon Dec 9 22:47:42 PST 2019
Thanks in Advance,
-
What does "uname -a" return ?
-
@SGaist ,
One more quick update from end is, now I am able to run the above example without crash. But again I stuck with same core problem where I want to read continuous frames from camera and do process on it.
The crash is happening due to below issue:
https://forums.developer.nvidia.com/t/mjpeg-patch-makes-jpegdec-segfault/119810The example which you pointed here, with that also image file has creating every capture call
Thanks in Advance,
-
Hi @SGaist ,
As per my understanding right, reading frame from camera is very basic operation any one can expect from QT camera API.
From one week I am working on this and I feel so difficult for reading frame using QCamera API.
I have been working with OpenCV its so straightforward
Looks like am I missing something ? Please kindly help on this.Thanks in Advance,
-
Qt uses GStreamer on Linux. If GStreamer has an issue, Qt can't do miracles.
-
@SGaist ,
Thanks for the information, is there any API by which I can access the Qimage other than capture API?
Because capture is doing both the things in my case, file saving and filling same data into Qimage object.
As we know right performance and memory consumption will affect due to file writes.Thanks in advance,
-
You said that you had it working the way you wanted with OpenCV. You can easily use it from Qt.