Help capturing an image
-
Sorry for the late reply but I'm unable to provide a minimal example. I've been digging around though and it seems to always crash after the signal imageAvailable(int id, const QVideoFrame &frame). I don't really know why that happens. I tried to do an
auto image = frame.toImage();
but this always crashes as well. I've looked into the camera example thats proved and in there it works fine -
Then I would compare what is done differently in your application based on the example.
-
Yeah I did that and mine looks like it should work. After looking some more though whenever I debug I get this error I do the frame.toImage().
Exception at 0x7ffa5092469e, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance)I saw online that this happens when it tries to access an invalid address but I don't see how this happens for me. This is how I have my imageAvailable
void VideoCapture::imageAvailable(int id, const QVideoFrame &frame){
QVideoFrame frame2(frame);
frame2.map(QVideoFrame::ReadOnly);
if (frame2.isValid())
{
qDebug() << "\n" << "frame2 is valid!\n";
}
else
qDebug() << "\n" << "frame2 is NOT valid!\n";if (frame2.isReadable()) { qDebug() << "\n" << "frame2 is readable!\n"; } else qDebug() << "\n" << "frame2 is NOT readable!\n"; if (frame2.isMapped()) { qDebug() << "\n" << "frame2 is mapped!\n"; } else qDebug() << "\n" << "frame2 is NOT mapped!\n"; qDebug() << "\n" << "frame2 map mode : " << frame2.mapMode() << "\n"; qDebug() << "\n" << "frame2 plane count : " << frame2.planeCount() << "\n"; qDebug() << "\n" << "frame2 size : " << frame2.size() << "\n"; qDebug() << "\n" << "frame2 pixelFormat : " << frame2.pixelFormat() << "\n"; qDebug() << "\n" << "frame2 mappedBytes_0 : " << frame2.mappedBytes(0) << "\n"; qDebug() << "\n" << "frame2 mappedBytes_1 : " << frame2.mappedBytes(1) << "\n"; qDebug() << "\n" << "frame2 mappedBytes_2 : " << frame2.mappedBytes(2) << "\n"; qDebug() << "\n" << "frame2 handleType : " << frame2.handleType() << "\n"; qDebug() << "\n" << "frame: " << frame << "\n"; qDebug() << "\n" << "frame2: " << frame2 << "\n";
qDebug() << "\n" << "before conversion\n";
frame2.toImage();
qDebug() << "\n" << "after conversion\n";}
the printout says that its valid, readable, it mapped, map mode is 1, plane count is 2, size is 1980X1080, pixel format is Format_NV12, mapped bytes for 0 is 2073600, mapped bytes for 1 is 1036800, mapped bytes for 2 is 0, no handle.
-
Yeah I did that and mine looks like it should work. After looking some more though whenever I debug I get this error I do the frame.toImage().
Exception at 0x7ffa5092469e, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance)I saw online that this happens when it tries to access an invalid address but I don't see how this happens for me. This is how I have my imageAvailable
void VideoCapture::imageAvailable(int id, const QVideoFrame &frame){
QVideoFrame frame2(frame);
frame2.map(QVideoFrame::ReadOnly);
if (frame2.isValid())
{
qDebug() << "\n" << "frame2 is valid!\n";
}
else
qDebug() << "\n" << "frame2 is NOT valid!\n";if (frame2.isReadable()) { qDebug() << "\n" << "frame2 is readable!\n"; } else qDebug() << "\n" << "frame2 is NOT readable!\n"; if (frame2.isMapped()) { qDebug() << "\n" << "frame2 is mapped!\n"; } else qDebug() << "\n" << "frame2 is NOT mapped!\n"; qDebug() << "\n" << "frame2 map mode : " << frame2.mapMode() << "\n"; qDebug() << "\n" << "frame2 plane count : " << frame2.planeCount() << "\n"; qDebug() << "\n" << "frame2 size : " << frame2.size() << "\n"; qDebug() << "\n" << "frame2 pixelFormat : " << frame2.pixelFormat() << "\n"; qDebug() << "\n" << "frame2 mappedBytes_0 : " << frame2.mappedBytes(0) << "\n"; qDebug() << "\n" << "frame2 mappedBytes_1 : " << frame2.mappedBytes(1) << "\n"; qDebug() << "\n" << "frame2 mappedBytes_2 : " << frame2.mappedBytes(2) << "\n"; qDebug() << "\n" << "frame2 handleType : " << frame2.handleType() << "\n"; qDebug() << "\n" << "frame: " << frame << "\n"; qDebug() << "\n" << "frame2: " << frame2 << "\n";
qDebug() << "\n" << "before conversion\n";
frame2.toImage();
qDebug() << "\n" << "after conversion\n";}
the printout says that its valid, readable, it mapped, map mode is 1, plane count is 2, size is 1980X1080, pixel format is Format_NV12, mapped bytes for 0 is 2073600, mapped bytes for 1 is 1036800, mapped bytes for 2 is 0, no handle.
@John1123 said in Help capturing an image:
Exception at 0x7ffa5092469e, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance)
This is a "first chance" exception. So far as I understand it, that is an MSVC-ism and is to be ignored as not relevant. Do you have any other problem/diagnostic other than a first chance exception?
-
Hi Jon, I don't have any other problem. When I build I don't get anything and when I run with the debugger on, that's the only issue that I have