2017-06-28 3 views
2

I Video-Streaming jetson TX1 abgeschlossen und mein PCWie kombiniere ich opencv und gstreamer?

jetzt opencvcode der Videoverarbeitung

so, ich will opencv Code anzupassen in jetson gstreamer

Next-Code ist PC-jetson TX1 Streaming Ich habe und opencv Code

//jetson code// 
 

 

 
CLIENT_IP=10.100.0.70 
 

 
gst-launch-1.0 nvcamerasrc fpsRange="30 30" intent=3 ! nvvidconv flip-method=6 \ 
 

 
! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)I420, framerate=(fraction)30/1' ! \ 
 

 
omxh264enc control-rate=2 bitrate=4000000 ! 'video/x-h264, stream-format=(string)byte-stream' ! \ 
 

 
h264parse ! rtph264pay mtu=1400 ! udpsink host=$CLIENT_IP port=5000 sync=false async=false 
 

 

 
// PC code// 
 

 
gst-launch-1.0 udpsrc port=5000 ! application/x-rtp,encoding-name=H264,payload=96 ! rtph264depay ! h264parse ! queue ! avdec_h264 ! xvimagesink sync=false async=false -e 
 

 

 

 
opencv code 
 

 

 
#include <opencv2/imgproc/imgproc.hpp> 
 
#include <opencv2/highgui/highgui.hpp> 
 

 
int main() 
 
{ 
 
    cv::Mat img,img_gray; 
 

 
    cv::VideoCapture input(0); 
 

 
    for(;;) 
 
    { 
 
    if (!input.read(img)) 
 
     break; 
 

 
    cv::cvtColor(img, img_gray, CV_RGB2GRAY); 
 

 
    cv::imshow("img", img); 
 
    cv::imshow("gray", img_gray); 
 
    char c = cv::waitKey(30); 
 

 
    if (c == 27) 
 
     break; 
 
    } 
 
}

Antwort

0

OpenCV-Unterstützung VideoCapture- und VideoWriter-Gstreamer-Pipes unterstützen Gstreamer-Pipes. Sie müssen Ihre Pipe als Parameter übergeben, der mit appsink/starting für appsrc endet.

char* inputPipe = "nvcamerasrc fpsRange="30 30" intent=3 ! nvvidconv flip-method=6 ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)I420, framerate=(fraction)30/1' ! videoconvert ! appsink"; 
char* outputPipe = "appsrc ! videoconvert ! omxh264enc control-rate=2 bitrate=4000000 ! 'video/x-h264, stream-format=(string)byte-stream' ! 264parse ! rtph264pay mtu=1400 ! udpsink host=$CLIENT_IP port=5000 sync=false async=false"; 

cv::VideoCapture input(inputPipe); 
cv::VideoWriter writer(outputPipe, 0, 25.0, cv::Size(1920,1080)); 
for(;;) 
{ 
if (!input.read(img)) 
    break; 

cv::cvtColor(img, img_gray, CV_RGB2GRAY); 
//cv::imshow("img", img); 
//cv::imshow("gray", img_gray); 
// instead of imshow pass the frame to VideoWriter 
writer.write(img_gray); 

char c = cv::waitKey(30); 

if (c == 27) 
    break; 
} 

Performance-Tipp:

OpenCV nutzt Videocapture verwendet BGR-Farbraum und nvcamerasrc den Ausgang auf I420 Farbraum. Wenn Sie das folgende Pipe-Videoconvert-Element verwenden, wird zu viel CPU verbraucht.

char* inputPipe = "nvcamerasrc fpsRange="30 30" intent=3 ! nvvidconv flip-method=6 ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)I420, framerate=(fraction)30/1' ! videoconvert ! appsink"; 

Stattdessen, wenn Sie Farbraum BGRx oder RGBA mit nvvidconv konvertieren, wird die Farbraumkonvertierung auf spezielle Hardware und die CPU-Auslastung wird deutlich niedriger sein getan werden

char* inputPipe = "nvcamerasrc fpsRange="30 30" intent=3 ! nvvidconv flip-method=6 ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)BGRx, framerate=(fraction)30/1' ! videoconvert ! appsink"; 
Verwandte Themen