How can pass raw data of RGB/BGR format to read

asked 2018-09-21 03:58:23 -0600

kishan patel gravatar image

updated 2018-09-21 04:59:53 -0600

berak gravatar image

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.

edit retag flag offensive close merge delete

Comments

1

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)

holger gravatar imageholger ( 2018-09-21 04:14:23 -0600 )edit

video file of raw_data in RGB/ BGR format

what exactly is this ? please be more concise.

also, we cannot help, without seing code here.

berak gravatar imageberak ( 2018-09-21 04:14:36 -0600 )edit

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() ) {

kishan patel gravatar imagekishan patel ( 2018-09-21 04:29:04 -0600 )edit

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.

kishan patel gravatar imagekishan patel ( 2018-09-21 04:30:20 -0600 )edit

error: [IMGUTILS @ 0x7ffccb6f6790] Picture size 0x0 is invalid

(app:3043): GLib-GObject-CRITICAL **: g_object_set: assertion 'G_IS_OBJECT (object)' failed

kishan patel gravatar imagekishan patel ( 2018-09-21 04:31:34 -0600 )edit

for heavens sake, put your code into your question, (where it belongs), not into comments.

berak gravatar imageberak ( 2018-09-21 04:35:55 -0600 )edit

Okay, Now fine?

kishan patel gravatar imagekishan patel ( 2018-09-21 04:50:33 -0600 )edit

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?

holger gravatar imageholger ( 2018-09-21 04:52:51 -0600 )edit

Yes, I have tried to use another video_file as you can see in code. I have comment out remaining video_files.

kishan patel gravatar imagekishan patel ( 2018-09-21 04:57:00 -0600 )edit

Yes, i am using sample code name objectdetection(path: samples/cpp/tutorialcode/objectdetection)

kishan patel gravatar imagekishan patel ( 2018-09-21 05:07:19 -0600 )edit

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.

holger gravatar imageholger ( 2018-09-21 05:10:31 -0600 )edit

Have you tried using an absolute file path? Maybe your working dir is different than you think.

holger gravatar imageholger ( 2018-09-21 05:12:23 -0600 )edit
1

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.

berak gravatar imageberak ( 2018-09-21 05:13:20 -0600 )edit

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.

holger gravatar imageholger ( 2018-09-21 05:15:08 -0600 )edit

Hello Holger, I have used same code as you provide me link. But same issue occur.

kishan patel gravatar imagekishan patel ( 2018-09-21 05:20:38 -0600 )edit

Hello Berak, do you mean that VideoCapture function can not open file with RAW data?

kishan patel gravatar imagekishan patel ( 2018-09-21 05:23:35 -0600 )edit

@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.

berak gravatar imageberak ( 2018-09-21 05:44:01 -0600 )edit

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"

kishan patel gravatar imagekishan patel ( 2018-09-21 05:50:25 -0600 )edit