Android Get Video Frames From video File

Post your Android related questions here.
Post Reply
Lafi
Posts: 1
Joined: Sun Sep 04, 2016 9:36 pm

Android Get Video Frames From video File

Post by Lafi » Sun Sep 04, 2016 9:45 pm

Hello,
i'm using EMGUCV v 3.3.1.1 with Xamarin for an android app, i want to get all video frame from a video file but always i have got an error

Code: Select all

Unhandled Exception:

System.NullReferenceException: Object reference not set to an instance of an object
here is my code

Code: Select all

 VideoCapture cap = new VideoCapture("storage/emulated/0/Download/12.MKV");
 Frame_Height = cap.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameHeight);
 Frame_width = cap.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameWidth);
	 while(i <= 10)
            {
               
                Mat image = new Mat( (int)Frame_Height,(int) Frame_width, DepthType.Cv8U, 3);
               

                image = cap.QueryFrame();                
               
                if((image != null))
                {
                    
                    imageView.SetImageBitmap(image.ToBitmap());
                    i++;
                    Console.WriteLine(i);

                }
                  
            }
           
        }
i don't know waht cause the error, please i need your help.
Thank you

adam.nosal
Posts: 2
Joined: Thu Dec 01, 2016 8:13 am

Re: Android Get Video Frames From video File

Post by adam.nosal » Thu Dec 01, 2016 8:14 am

I'm having the same problem. Did you manage to find whats the problem ?

adam.nosal
Posts: 2
Joined: Thu Dec 01, 2016 8:13 am

Re: Android Get Video Frames From video File

Post by adam.nosal » Tue Dec 06, 2016 6:07 am

I have a problem using EmguCV to load a file in VideoCapture constructor.

The constructor always return some empty VideoCapture and calling QueryFrame always return null.

Did Anyone Have similiar issues ? What am i doing wrong ?

Here is some Code snippet from my exampleProject:

Code: Select all

                var file = await CrossMedia.Current.PickVideoAsync();
            /.../
                _localCapture = new VideoCapture(file.Path);
                _localCapture.Start();
                _localCapture.ImageGrabbed += _localCapture_ImageGrabbed;
           /.../
              bool GrabResult =   _localCapture.Grab();
               Mat frame =  _localCapture.QueryFrame();
              UpdateConsole("Video Selected Location: GRAB TEST RESULT " + GrabResult);
Link to the ExampleProject : https://drive.google.com/file/d/0B8yxP5 ... sp=sharing in the project is //TODO line where is the Emgu code

If you are reading this thanks you for stoping by. Any thoughts about possible mistakes in code would be helpfull.

jhorv
Posts: 1
Joined: Wed Dec 07, 2016 11:15 am

Re: Android Get Video Frames From video File

Post by jhorv » Wed Dec 07, 2016 11:19 am

I'm having a similar problem - I'm trying to open the device camera without success. I've tried every possible Emgu.CV.CvEnum.CaptureType and they all return a VideoCapture object that has IsOpened == false. I've also tried specific camera indexes 0 and 1 with no success.

It fails both in an Android emulator (the Visual Studio Hyper-V one), and on an actual Android device (Fire HD 10 5th gen).

Post Reply