Home > Software engineering >  Under the ubuntu with gstreamer obtain camera data and how to get per frame to opencv image processi
Under the ubuntu with gstreamer obtain camera data and how to get per frame to opencv image processi

Time:09-25

This is the call and show a camera I wrote the code, how to get every frame image data? (get data for Oencv processing), hope to get specific methods or code, I am just contact us, thank you,
 # include & lt; GST/GST. H> 

# define Device_path_1 "/dev/video0
"//# define Device_path_2 "/dev/video1"
# define Camera_caps "video/x - raw - yuv, width=1920 (int), height=(int) 1080, framerate=30/1 (fraction)"

Int main (int arg c, char * argv [])
{
Sink_1 convert_1 camera_source_1 GstElement * and * and * and * pipeline;
GMainLoop * loop;

//initialize the GST
Gst_init (& amp; Arg c, & amp; Argv);

//create need elements
Camera_source_1 v4l2src camera_source_1=gst_element_factory_make (" ", "");
Convert_1=gst_element_factory_make (" ffmpegcolorspace ", "1 _csp");
Sink_1 ximagesink sink_1=gst_element_factory_make (" ", "");


//create a pipeline
Camera_pipeline pipeline=gst_pipeline_new (" ");

//error handling
if(! Pipeline | |! Camera_source_1 | |! Sink_1 | |! Convert_1) {
G_printerr (" Not all elements could be created! \n");
return -1;
}

//configuration elements
G_object_set (G_OBJECT (camera_source_1), "device", Device_path_1, NULL);

//link all elements
Gst_bin_add_many (GST_BIN (pipeline), camera_source_1, convert_1, sink_1, NULL);


Gst_element_link_many (camera_source_1, convert_1 sink_1, NULL);

Gst_element_set_state (pipeline, GST_STATE_PLAYING);
Loop=g_main_loop_new (NULL, FALSE);
G_main_loop_run (loop);
G_print (" stopping sender pipeline \ n ");
Gst_element_set_state (pipeline, GST_STATE_NULL);
return 0;
}

CodePudding user response:

Baidu search relevant keywords,

CodePudding user response:

Zhao four teacher hello, I checked the relevant information, and through the source Insight view source, didn't find a better template, a few problems

CodePudding user response:

Question: 1. Appsrc configured source, don't know how to join device path such as/dev/video0

CodePudding user response:

Question: 2. How to make the buffer to receive the data

CodePudding user response:

Don't be A language code is modified to B language code busywork,
Also don't use A language code to directly invoke B language code base, this complicated things so easy to get wrong,
Just make A, B language code of input and output is redirected to A text file, or modify A, B language code let it through text file input and output,
Can easily make A, B coordination between the two languages,
For example:
A will request data written to A file a.t xt, renamed after finish aa. TXT
B find aa. TXT, read its contents, call the corresponding function, and writes the results file b.t xt, after finish delete aa. TXT, changed its name to bb. TXT
Found A bb. TXT, read the content, after finish delete bb. TXT
Above can be replaced by any kind of A language or development environment, B can be replaced by any kind of with the development of A different language or development environment,
Unless A or B does not support to determine whether A file exists, file read and write and file name,
But who can name does not support to determine whether a file exists, file read and write and file name for the development of language or development environment?
Can put the temporary files on the RamDisk efficiency decrease wear disk,
Data structure is very complex, a text file format problems refer to a json or XML

The communication methods between the temporary text file sharing this process there are plenty of advantages, compared to other method only listed below I can think of now:
Loose coupling between process,
Can be on the same machine, process, also can cross machine, across the operating system, hardware platform, and even multinational,
, convenient debugging, and monitoring, only let the third party or artificial view the temporary text files,
Switch, convenient online service, need to delete or create the temporary text files,
, is convenient to realize distributed and load balancing,
Services to provide convenient, queue, queue is full and it is almost impossible to happen (unless the hard disk space full)
DE...

"Across different languages, machine, across the operating system, hardware platform, multinational, cross *. *" misery,
Back is "the use of Shared a plain text file information communication" of the shore!

CodePudding user response:

Why use it directly with opencv bring gstreamer VideoCapture o can add a pipeline decoding effect is much better than before

CodePudding user response:

Blogger you set Camera_caps if not used
  • Related