How can pass raw data of RGB/BGR format to read
Actually, When i open video file of raw_data in RGB/ BGR format. It could not open. What should be wrong with this?
Please check lines of code as below:
/**
* @function main
*/
int main( void )
{
VideoCapture capture;
Mat frame;
//-- 1. Load the cascades
if( !face_cascade.load( face_cascade_name ) ){ printf("--(!)Error loading\n"); return -1; };
if( !eyes_cascade.load( eyes_cascade_name ) ){ printf("--(!)Error loading\n"); return -1; };
//-- 2. Read the video stream
//capture.open( -1 );
//capture.open("test_rgb.mp4");
//capture.open("vid_web_input1.mov");
capture.open("video_test.rgb");
//capture.open("rgb.avi");
//capture.open("1.rgb");
//capture.open("2.rgb");
//capture.open("rtsp://admin:jenex#[email protected]:554");
//capture.open("rgb.mov");
//capture.open("/home/kishan/HD_CAM_1280_720.avi");
//capture.open(0);
if( capture.isOpened() )
{
int total_frames = 0;
int frame_width, frame_height;
//char frame_codec_type[6]={0};
double frame_codec_type=0;
total_frames = capture.get(CV_CAP_PROP_FRAME_COUNT);
frame_width = capture.get(CV_CAP_PROP_FRAME_WIDTH);
frame_height = capture.get(CV_CAP_PROP_FRAME_HEIGHT);
frame_codec_type = capture.get(CV_CAP_PROP_FOURCC);
printf("\nNo. of Frames= %d\nwidth= %d\nheight= %d\ntype= %lf\n",total_frames, frame_width, frame_height, frame_codec_type);
for(;;)
{
capture >> frame;
//-- 3. Apply the classifier to the frame
if( !frame.empty() )
{ detectAndDisplay( frame ); }
else
{ printf(" --(!) No captured frame -- Break!"); break; }
int c = waitKey(10);
if( (char)c == 'c' ) { break; }
Regards, Kishan Patel.
It could not open. What should be wrong with this? Too general, please provide error messages and relevant code pieces, otherwise people cannot help you.
I am assuming your have a video encoded with a specific codec and want to read in the frames. The class for capturing frames is VideoCapture. If you have a problem with that you either have encoding problems (my guess now) or some hardware related problems (camera)
what exactly is this ? please be more concise.
also, we cannot help, without seing code here.
Okay, if( !face_cascade.load( face_cascade_name ) ){ printf("--(!)Error loading\n"); return -1; }; if( !eyes_cascade.load( eyes_cascade_name ) ){ printf("--(!)Error loading\n"); return -1; };
//-- 2. Read the video stream //capture.open( -1 ); //capture.open("test_rgb.mp4"); //capture.open("vid_web_input1.mov"); capture.open("video_test.rgb"); //capture.open("rgb.avi"); //capture.open("1.rgb"); //capture.open("2.rgb"); //capture.open("rtsp://admin:jenex#[email protected]:554"); //capture.open("rgb.mov"); //capture.open("/home/kishan/HD_CAM_1280_720.avi"); //capture.open(0); if( capture.isOpened() ) {
I have just open and play video file of raw data in RGB/BGR format. This video file can be play by "vooya" software in ububtu system.
error: [IMGUTILS @ 0x7ffccb6f6790] Picture size 0x0 is invalid
(app:3043): GLib-GObject-CRITICAL **: g_object_set: assertion 'G_IS_OBJECT (object)' failed
for heavens sake, put your code into your question, (where it belongs), not into comments.
Okay, Now fine?
Well if you have problems - try to split it - Can you try the video capture part on another video and see if you can capture at all?
Your error message includes the following part: " [IMGUTILS @ 0x7ffccb6f6790] Picture size 0x0 is invalid"
Can you also try out the sample code from the video capture sample on your video?
Yes, I have tried to use another video_file as you can see in code. I have comment out remaining video_files.
Yes, i am using sample code name objectdetection(path: samples/cpp/tutorialcode/objectdetection)
Could you try this code - https://docs.opencv.org/3.0-beta/modu...
And just modify line VideoCapture cap(0)
to use an absolute path VideoCapture cap("/path/to/video.avi")
Maybe sounds stupid to you but try to keep as small as possible.
Have you tried using an absolute file path? Maybe your working dir is different than you think.
so, it tried to open it, but likely could not deduce the img size (in absence of useful headers) from it.
it might simply be, that you cannot use this video with opencv's VideoCapture as is.
you could still try to recompress / reformat it using ffmpeg or such.
Oh so he could open the other videos - not only this rgb one - communication ^^ So berak gave already the right answer. Just encode that video with ffmpeg and then read it in.
Hello Holger, I have used same code as you provide me link. But same issue occur.
Hello Berak, do you mean that VideoCapture function can not open file with RAW data?
@kishan, no i mean, that "raw" only means absence of any useful information, there is no specification for it. it could be rgb/bgr or even some native yuv, straight from the sensor. in your case it simply did not know, what to do with it.
why it is so, and what exactly it can do ... ufff. you would have to looks at the cap_gstreamer or cap_ffmpeg src, to find out.
I have used gstreamer to save data in RGB format as like "gst-launch-1.0 --gst-debug=vpe:3 -v rtspsrc location=rtsp://888888:[email protected]:554 ! rtph264depay ! h264parse ! ducatih264dec ! vpe ! 'video/x-raw, format=(string)RGB, width=(int)640, height=(int)480' ! filesink location=test.rgb -v"