javacv development explain the 1: call the native camera video

Preface: javacv java development kit is used to support the development of a multimedia development kit can be applied to local multimedia (audio and video) calls, and audio and video, pictures and other files post-operation (photo editing, audio and video clips decoding function, etc.), here only the most simple local call camera to show you the basic functions javacv
important:

recommended javaCV1.3 the latest version, this version has resolved most of the bug has been found in earlier versions of

javacv series using 6 jar package:

javacv .jar, javacpp.jar, ffmpeg.jar, ffmpeg- platform .jar, opencv.jar, opencv- platform .jar.

Wherein ffmpeg- platform .jar, opencv- .jar Platform Platform in accordance with a development environment or test environment deployment make changes to the corresponding jar package, such windows7 64-bit system is replaced ffmpeg-x86-x64.jar

why such do: because ffmpeg- platform .jar is stored in c / c ++ locally so / dll library, ffmpeg.jar is achieved using the corresponding local interface javacpp library java package, and is based javacpp jni functionality of a capsule to facilitate the realization jni, javacv.jar is nine visual library of the second package, but achieved limited functionality, it is recommended that novice become familiar with API after openCV and ffmpeg both C / C ++ library will look javaCV ideas very clear.

Notes:

javacv series default audio and video processing using ffmpeg, image processing using opencv, grab the camera using OpenCV

javacv official github maintenance Address: HTTPS: //github.com/bytedeco/javacv
1, using the latest javacv1.4.4
(Note: Downloading from the rest of the dependent packages please replace active happy to provide official jar package jar package and bloggers; if other jar package version and lead to errors, do not hurry to find bloggers ask why will complain, first jar Alternatively the package try again)
(1) adding a dependency maven

      <dependency>
        <the groupId> org.bytedeco </ the groupId>
        <the artifactId> javacv-Platform </ the artifactId>
        <Version> 1.4.4 </ Version>
      </ dependency >

 
(2) adding a dependency gradle

    Dependencies {
        the compile Group: 'org.bytedeco', name: 'javacv-Platform', Version: '1.4.4'
      }

 
(. 3) using a local packet mode jar

latest version is too great, need Download the full amount of the package go to the official github.com/bytedeco/javacv download

javaCV1.3.3 version download (full amount of the package, the file name: javacv-platform-1.3.3-bin.zip, size: 212M): http: // download . csdn.net/download/eguid_1/10146035

javaCV1.3 version download:

1, javacv1.3 core package: http: //download.csdn.net/detail/eguid_1/9716960 (containing javacv.jar, javacpp.jar-platform.jar and javacv)

2, javacv1.3-OpenCV package collection: http : //download.csdn.net/detail/eguid_1/9716965

. 3, javacv1.3-FFmpeg package set: HTTP: //download.csdn.net/detail/eguid_1/9719323

javaCV1.3 all jar package collection: http: / /download.csdn.net/detail/eguid_1/9719343

javaCV1.2 all the jar packages collection download here: http: //download.csdn.net/album/detail/3171

 

following section is javacv1.2 version, is no longer recommended download

basic dependencies: javacv.jar; javacpp.jar (must be 1.2 or later)

 

JAR package instructions:

Windows platform used opencv x64-dependent: opencv.jar; oepncv-windows-x86_64.jar ( corresponding to replace other platforms jar package can).

Added:

1, if Apple mac system, replacing oepncv-windows-x86_64.jar into this bag-macosx-x86_64.jar OpenCV
2, replace the Linux platform package: opencv-linux-x86_64.jar  

3, Android platform replaced opencv-android-arm.jar or Android-x86.jar-OpenCV

Maven gradle manner and if you want to decrease the packet size dependence, it is necessary to manually exclude undesirable to rely on internet

 
2, why not you need to install opencv?

From javacv0.8 start, it has no local installation opencv, opencv reference packet corresponding to the platform directly by reference.

(Such oepncv-windows-x86_64.jar is a typical 64-bit windows environment dependencies)

 
. 3, Java acquisition windows of the video camera by javacv

camera live video interface final call:

a simple preview native camera video image:

 

    / * *
     * file name: javavcCameraTest.java
     * description: call the windows platform camera video window
     * modified: June 13, 2016
     * content:
     * /
    Package Penalty for cc.eguid.javacv;
     
    Import javax.swing.JFrame;
     
    Import ORG .bytedeco.javacv.CanvasFrame;
    Import org.bytedeco.javacv.OpenCVFrameConverter;
    Import org.bytedeco.javacv.FrameGrabber.Exception;
    org.bytedeco.javacv.OpenCVFrameGrabber Import;
     
    / **
     * call local camera video window
     * @author eguid  
     * @version 2016 Nian 6 Yue 13 Ri  
     * @see javavcCameraTest  
     * @Since javacv1.2
     * /
     
    public class JavavcCameraTest
    {
    public static void main (String [] args) throws Exception, InterruptedException
    {
        OpenCVFrameGrabber = new new OpenCVFrameGrabber in Glover (0);  
        grabber.start (); // start obtaining camera data
        CanvasFrame canvas = new CanvasFrame ( "camera"); // Create a window
        canvas .setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
        canvas.setAlwaysOnTop (to true);
        
        the while (to true)
        {
            (! canvas.isDisplayable ()) IF
            {// the window is closed
                grabber.stop (); // stop crawling
                System.exit (2); // Exit
            }
            canvas.showImage (grabber.grab ()); // and acquired camera images onto the display window, where frame frame = grabber.grab (); frame is a video image
     
            Thread.sleep (50); // 50 milliseconds to refresh the image
        }
    }
    }

Guess you like

Origin www.cnblogs.com/riverone/p/11690116.html