get camera frame on Android (PC is ok)
-
header file content:
class FilterTestRunnable : public QVideoFilterRunnable
{
private:
FilterTest *m_filter;//void deleteColorComponentFromYUV(QVideoFrame *input);
public:
FilterTestRunnable(FilterTest *filter) : m_filter(filter) { }
QVideoFrame run(QVideoFrame input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags);
};
cpp file content:
QVideoFilterRunnable FilterTest::createFilterRunnable()
{
return new FilterTestRunnable(this);
}QVideoFrame FilterTestRunnable::run(QVideoFrame *input,
const QVideoSurfaceFormat &surfaceFormat,
QVideoFilterRunnable::RunFlags flags)
{
if (!input->isValid())
return *input;QAbstractVideoBuffer::MapMode mode = input->mapMode(); input->map(QAbstractVideoBuffer::ReadWrite); if(input->isReadable()){ qWarning() << "Is readable!"; } input->unmap(); return *input;
}
problem:
Always print "QVideoFrame::unmap() was called more times then QVideoFrame::map()"
“input->isReadable()” is always false -
Hi and welcome to devnet,
IIRC, on Android the the QVideoFrame contains a texture. You should check the QAbstractVideoBuffer::HandleType of it.
-
@SGaist
did you mean like this:(This is someone else's code, I don't know what it does, and there is the usage of the handleType you mentioned.)
QListQVideoFrame::PixelFormat supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const
{
Q_UNUSED(handleType);
return QListQVideoFrame::PixelFormat()
<< QVideoFrame::Format_ARGB32
<< QVideoFrame::Format_ARGB32_Premultiplied
<< QVideoFrame::Format_RGB32
<< QVideoFrame::Format_RGB24
<< QVideoFrame::Format_RGB565
<< QVideoFrame::Format_RGB555
<< QVideoFrame::Format_ARGB8565_Premultiplied
<< QVideoFrame::Format_BGRA32
<< QVideoFrame::Format_BGRA32_Premultiplied
<< QVideoFrame::Format_BGR32
<< QVideoFrame::Format_BGR24
<< QVideoFrame::Format_BGR565
<< QVideoFrame::Format_BGR555
<< QVideoFrame::Format_BGRA5658_Premultiplied
<< QVideoFrame::Format_AYUV444
<< QVideoFrame::Format_AYUV444_Premultiplied
<< QVideoFrame::Format_YUV444
<< QVideoFrame::Format_YUV420P
<< QVideoFrame::Format_YV12
<< QVideoFrame::Format_UYVY
<< QVideoFrame::Format_YUYV
<< QVideoFrame::Format_NV12
<< QVideoFrame::Format_NV21
<< QVideoFrame::Format_IMC1
<< QVideoFrame::Format_IMC2
<< QVideoFrame::Format_IMC3
<< QVideoFrame::Format_IMC4
<< QVideoFrame::Format_Y8
<< QVideoFrame::Format_Y16
<< QVideoFrame::Format_Jpeg
<< QVideoFrame::Format_CameraRaw
<< QVideoFrame::Format_AdobeDng;
} -
@bigbao said in get camera frame on Android (PC is ok):
how to change " UNSOLVED" to " SOLVED"
https://forum.qt.io/topic/71830/hitchhiker-s-visual-guide-to-the-qt-forum
-
@SGaist
Hi, in thant code,I want to know supportedViewfinderResolutions of camera,so the main.qml is:ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("My Video Filter")Camera { id: camera //viewfinder.resolution: "320x240" //viewfinder.resolution: "600x400" } VideoOutput { id: videoOutput anchors.fill: parent autoOrientation: true source: camera filters: [ videoFilter ] } MyVideoFilter { id: videoFilter orientation: videoOutput.orientation } MouseArea{ id: mousearea anchors.fill: parent onClicked: show_frame_rate() } function show_frame_rate() { console.log(camera.viewfinder.resolution) console.log(camera.viewfinder.supportedViewfinderResolutions) //there is problem: /* print qml: QSize(-1, -1) qml: undefined */ }
}
I don't konw why , I can't get :
print info:
qml: QSize(-1, -1)
qml: undefined
is it possible to get those info in my filter:
class MyVideoFilterRunnable : public QVideoFilterRunnable
{
public:
MyVideoFilterRunnable(MyVideoFilter* parent = nullptr);QVideoFrame run(QVideoFrame *input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags) Q_DECL_OVERRIDE; QVideoFrame run(QVideoFrame *input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags, QImage image);
protected:
MyVideoFilter* m_Filter;
int m_Orientation;
int m_Flip;
}; -
The backend might have some limitation there.
Out of curiosity, what do you need these values for ?