Home JavaCV pass video frame to imread()
Reply: 0

JavaCV pass video frame to imread()

Tina J
Tina J Published in 2017-12-06 18:03:23Z

I'm trying to use JavaCV for template matching. The demo example is located here. I add all their .jar files to the project. I need to pass a video frame (say video.mp4's last frame) to imread() instead of it reading the source image from file. How can I do that?

String [] arg={"laff.png","template.png"};
FrameGrabber grabber = new FFmpegFrameGrabber("video.mp4");
System.out.println(grabber.getFrameRate());    //returns 0???

// read in image default colors
Mat sourceColor = imread(args[0]);   // pass last frame of video.mp4 instead of args[0]

UPDATE: I now can pass [the first] video frame to imread() using the following way (key point is to call start()). So I got the conversion done. Now I need to know how to grab a particular frame number, say the last frame.

FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("video.mp4");
OpenCVFrameConverter.ToMat converter = new OpenCVFrameConverter.ToMat();
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.302098 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO