Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

Analyse image from a video/avc (h264) Android

$
0
0
Hi I want to analyse the frames from a streaming which is using a h264 encoding format. this is the code I have to show each frame in a surfaceview inside the frame I have an array of byte which has the information of the next frame. public void displayFrame(ARFrame frame) { mReadyLock.lock(); if ((mMediaCodec != null)) { if (mIsCodecConfigured) { // Here we have either a good PFrame, or an IFrame int index = -1; try { index = mMediaCodec.dequeueInputBuffer(VIDEO_DEQUEUE_TIMEOUT); } catch (IllegalStateException e) { Log.e(TAG, "Error while dequeue input buffer"); } if (index >= 0) { ByteBuffer b; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { b = mMediaCodec.getInputBuffer(index); } else { b = mBuffers[index]; b.clear(); } if (b != null) { b.put(frame.getByteData(), 0, frame.getDataSize()); } try { mMediaCodec.queueInputBuffer(index, 0, frame.getDataSize(), 0, 0); } catch (IllegalStateException e) { Log.e(TAG, "Error while queue input buffer"); } } } // Try to display previous frame MediaCodec.BufferInfo info = new MediaCodec.BufferInfo(); int outIndex; try { outIndex = mMediaCodec.dequeueOutputBuffer(info, 0); while (outIndex >= 0) { mMediaCodec.releaseOutputBuffer(outIndex, true); outIndex = mMediaCodec.dequeueOutputBuffer(info, 0); } } catch (IllegalStateException e) { Log.e(TAG, "Error while dequeue input buffer (outIndex)"); } } mReadyLock.unlock(); } My doubt is, in which part of this code can I extract the image to make it compatible with openCV and create a Mat variable so I can analyse the image Thanks in advance

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>