Hi,everyone
I’m working on a project that needs to capture video from a usb2.0 camera on TX2. And my enviroment is Ubuntu L4T 28.1 on TX2,opencv3.2 compiled with gstreamer.
The output parameters of the USB2.0 Camera are 1920*1080, 30fps, encoding in mjpeg.
Following the instructions on “Jetson_TX2_Accelerated_GStreamer_User_Guide.pdf”(https://developer.nvidia.com/embedded/dlc/l4t-tx2-accelerated-gstreamer-guide-28-1),I can successfully watch the video using the follow gstreamer pipeline in terminal.
gst-launch-1.0 v4l2src device="/dev/video0" ! "video/x-raw, width=(int)1920, height=(int)1080, format=(string)I420" ! nveglglessink
gst-launch-1.0 v4l2src device="/dev/video0" ! nvjpegdec ! nveglglessink
According the pipeline, I wrote my code as shown below
int main(int argc, char *argv[])
{
const char *videosrc = "v4l2src device=/dev/video0 ! video/x-raw, width=(int)1920, height=(int)1080, format=(string)I420 ! videoconvert ! appsink";
cv::VideoCapture cap;
cap.open(videosrc);
if (!m_cap.isOpened())
{
std::cout<<"OPEN CAM ERROR\n";
return 1;
}
cv::Mat nowMat;
char ch;
while (true)
{
if(!cap.read(nowMat))
{
break;
}
//some code for processing the nowMat
cv::imshow("Hello", nowMat);
ch = cv::waitKey(1);
if(ch == 'q')break;
}
cap.release();
nowMat.release();
return 0;
}
Because my processing for nowMat is a little complex, the video is caton.And I saw CPUs on TX2 are high load, but GPU isn’t high load.
So, is there any way to capture and decode the video stream via GPU in my project,such as modifing the string passed to cap.open().
And because my code for processing is based on opencv3.2, I don’t want to rewrite my code on another framework.
Thanks