cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
deepg799
Explorer
Explorer
1,358 Views
Registered: ‎01-20-2019

OpenCV compilation with h264/265 Support

 

Is there any way to compile the OpenCV library with VCU hard codec support (h264/265) instead of using the Soft-core to encode/decode the video data.

Thank in advance.

 

0 Kudos
7 Replies
watari
Professor
Professor
1,350 Views
Registered: ‎06-16-2013

Hi @deepg799 

 

If you enable openmax library to support VCU in petalinux, you can describe your source code with gstreamer (openmax) in opencv.

 

Best regards,

deepg799
Explorer
Explorer
1,342 Views
Registered: ‎01-20-2019

@watari 

Thanks for the update.

is there any example code is available for the same? 

0 Kudos
deepg799
Explorer
Explorer
1,310 Views
Registered: ‎01-20-2019

@watari 

I am trying with the following code.

string gst_pipeline = " latency=0 io-mode=4 ! rtph264depay ! h264parse ! queue ! video/x-h264, alignment=nal ! omxh264dec internal-entropy-buffers=5 low-latency=1 ! queue ! videoscale method=0 ! video/x-raw, width=640,height=360 ! vi
deoconvert ! appsink sync=false async=false";

gst_pipeline = IP + gst_pipeline;
cv::VideoCapture cap(gst_pipeline,cv::CAP_GSTREAMER);

VideoWriter video;
video.open("appsrc ! autovideoconvert ! omxh265enc ! matroskamux ! filesink location=test.mkv sync=false",cv::CAP_GSTREAMER,0,(double)15,Size(1920,1080),true);

Mat img;
Mat img_re;
while(1){
cap.read(img);
cv::imshow("Ch-1", img); // working fine
resize(img,img_re,Size(1920,1080));
video.write(img_re); // not encoding & wrinting to the file.
}



By using the above code I can capture, decode & display the video frame. But when I am trying to encode the Mat img_re image then I am getting the below warning message.:

!! Warning : Adapting profile to support bitdepth and chroma mode
!! The specified Level is too low and will be adjusted !!

0 Kudos
watari
Professor
Professor
1,251 Views
Registered: ‎06-16-2013

Hi @deepg799 

 

Did you prepare proper streaming data and/or set proper caps. on gstreamer pipeline ?

 

Best regards,

0 Kudos
deepg799
Explorer
Explorer
1,213 Views
Registered: ‎01-20-2019

@watari 

Currently, my VCU conf. is as shown below set for YUV color format.

dpu_conf.png

 

 

But in the programming, I am giving the BGR color format frame to the encoder. I think that is the mistake I am doing.

Can u recommend a suitable configuration of the VCU for the BGR format encoding?

 

Thank you in advance.

 

 

0 Kudos
deepg799
Explorer
Explorer
1,176 Views
Registered: ‎01-20-2019

@watari 

It will be very helpful for me if you can share any sample code/application for the openmax library

0 Kudos
watari
Professor
Professor
1,059 Views
Registered: ‎06-16-2013

Hi @deepg799 

 

Read PG252 and refer ex. the following.

 

https://www.xilinx.com/support/documentation/ip_documentation/vcu/v1_2/pg252-vcu.pdf#page=122

 

Best regards,

0 Kudos