kandi background
Explore Kits

javacv | Java interface to OpenCV, FFmpeg, and more | Computer Vision library

 by   bytedeco Java Version: 1.5.6 License: Non-SPDX

 by   bytedeco Java Version: 1.5.6 License: Non-SPDX

Download this library from

kandi X-RAY | javacv Summary

javacv is a Java library typically used in Artificial Intelligence, Computer Vision, OpenCV applications. javacv has no bugs, it has no vulnerabilities, it has build file available and it has high support. However javacv has a Non-SPDX License. You can download it from GitHub, Maven.
JavaCV uses wrappers from the [JavaCPP Presets](https://github.com/bytedeco/javacpp-presets) of commonly used libraries by researchers in the field of computer vision ([OpenCV](http://opencv.org/), [FFmpeg](http://ffmpeg.org/), [libdc1394](http://damien.douxchamps.net/ieee1394/libdc1394/), [FlyCapture](https://www.flir.com/products/flycapture-sdk/), [Spinnaker](https://www.flir.com/products/spinnaker-sdk/), [OpenKinect](http://openkinect.org/), [librealsense](https://github.com/IntelRealSense/librealsense), [CL PS3 Eye Driver](https://codelaboratories.com/downloads/), [videoInput](http://muonics.net/school/spring05/videoInput/), [ARToolKitPlus](https://launchpad.net/artoolkitplus), [flandmark](https://github.com/uricamic/flandmark), [Leptonica](http://www.leptonica.org/), and [Tesseract](https://github.com/tesseract-ocr/tesseract)) and provides utility classes to make their functionality easier to use on the Java platform, including Android. JavaCV also comes with hardware accelerated full-screen image display (CanvasFrame and GLCanvasFrame), easy-to-use methods to execute code in parallel on multiple cores (Parallel), user-friendly geometric and color calibration of cameras and projectors (GeometricCalibrator, ProCamGeometricCalibrator, ProCamColorCalibrator), detection and matching of feature points (ObjectFinder), a set of classes that implement direct image alignment of projector-camera systems (mainly GNImageAligner, ProjectiveTransformer, ProjectiveColorTransformer, ProCamTransformer, and ReflectanceInitializer), a blob analysis package (Blobs), as well as miscellaneous functionality in the JavaCV class. Some of these classes also have an OpenCL and OpenGL counterpart, their names ending with CL or starting with GL, i.e.: JavaCVCL, GLCanvasFrame, etc. To learn how to use the API, since documentation currently lacks, please refer to the [Sample Usage](#sample-usage) section below as well as the [sample programs](https://github.com/bytedeco/javacv/tree/master/samples/), including two for Android (FacePreview.java and RecordActivity.java), also found in the samples directory. You may also find it useful to refer to the source code of [ProCamCalib](https://github.com/bytedeco/procamcalib) and [ProCamTracker](https://github.com/bytedeco/procamtracker) as well as [examples ported from OpenCV2 Cookbook](https://github.com/bytedeco/javacv-examples/) and the associated [wiki pages](https://github.com/bytedeco/javacv-examples/tree/master/OpenCV_Cookbook). Please keep me informed of any updates or fixes you make to the code so that I may integrate them into the next release. Thank you! And feel free to ask questions on [the mailing list](http://groups.google.com/group/javacv) or [the discussion forum](https://github.com/bytedeco/javacv/discussions) if you encounter any problems with the software! I am sure it is far from perfect…​.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • javacv has a highly active ecosystem.
  • It has 5658 star(s) with 1373 fork(s). There are 254 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 227 open issues and 1383 have been closed. On average issues are closed in 134 days. There are 3 open pull requests and 0 closed requests.
  • It has a positive sentiment in the developer community.
  • The latest version of javacv is 1.5.6
javacv Support
Best in #Computer Vision
Average in #Computer Vision
javacv Support
Best in #Computer Vision
Average in #Computer Vision

quality kandi Quality

  • javacv has 0 bugs and 0 code smells.
javacv Quality
Best in #Computer Vision
Average in #Computer Vision
javacv Quality
Best in #Computer Vision
Average in #Computer Vision

securitySecurity

  • javacv has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • javacv code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
javacv Security
Best in #Computer Vision
Average in #Computer Vision
javacv Security
Best in #Computer Vision
Average in #Computer Vision

license License

  • javacv has a Non-SPDX License.
  • Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.
javacv License
Best in #Computer Vision
Average in #Computer Vision
javacv License
Best in #Computer Vision
Average in #Computer Vision

buildReuse

  • javacv releases are available to install and integrate.
  • Deployable package is available in Maven.
  • Build file is available. You can build the component from source.
  • Installation instructions, examples and code snippets are available.
  • javacv saves you 22641 person hours of effort in developing the same functionality from scratch.
  • It has 44978 lines of code, 2078 functions and 116 files.
  • It has high code complexity. Code complexity directly impacts maintainability of the code.
javacv Reuse
Best in #Computer Vision
Average in #Computer Vision
javacv Reuse
Best in #Computer Vision
Average in #Computer Vision
Top functions reviewed by kandi - BETA

kandi has reviewed javacv and discovered the below as its top functions. This is intended to give you an instant insight into javacv implemented functionality, and help decide if they suit your requirements.

  • Performs blobs analysis on the input image
  • Sets hysteresis threshold .
  • Record samples .
  • Performs regularization .
  • Finds the squares in the given image .
  • Release unsafe data .
  • Detects markers inside an image .
  • Starts the video filtering .
  • Calculates stereo calibration .
  • Clone the source buffers .

javacv Key Features

Java interface to OpenCV, FFmpeg, and more

Downloads

copy iconCopydownload iconDownload
  <dependency>
    <groupId>org.bytedeco</groupId>
    <artifactId>javacv-platform</artifactId>
    <version>1.5.6</version>
  </dependency>

Sample Usage

copy iconCopydownload iconDownload
import org.bytedeco.opencv.opencv_core.*;
import org.bytedeco.opencv.opencv_imgproc.*;
import static org.bytedeco.opencv.global.opencv_core.*;
import static org.bytedeco.opencv.global.opencv_imgproc.*;
import static org.bytedeco.opencv.global.opencv_imgcodecs.*;

public class Smoother {
    public static void smooth(String filename) {
        Mat image = imread(filename);
        if (image != null) {
            GaussianBlur(image, image, new Size(3, 3), 0);
            imwrite(filename, image);
        }
    }
}

Build Instructions

copy iconCopydownload iconDownload
Project lead: Samuel Audet [samuel.audet `at` gmail.com](mailto:samuel.audet at gmail.com)
Developer site: https://github.com/bytedeco/javacv
Discussion group: http://groups.google.com/group/javacv

Create a video form images and videos and add audio to it programatically | Java, Python, ffmpeg

copy iconCopydownload iconDownload
String ffmpeg = Loader.load(org.bytedeco.ffmpeg.ffmpeg.class);
        ProcessBuilder processBuilder = new ProcessBuilder(
                ffmpeg,
                "-loop", "1",
                "-framerate", "30",
                "-t", "4",
                "-i", "image1.jpg",
                "-i", "video1.mp4",
                "-loop", "1",
                "-framerate", "30",
                "-t", "4",
                "-i", "image2.jpg",
                "-loop", "1",
                "-framerate", "30",
                "-t", "4",
                "-i", "image3.jpg",
                "-t" 4, "-i", "audio1.mp3",
                "-ss" 4, "-t", 8, "audio1.mp3",
                "-filter_complex", 
                "[0][1:v][2][[3]concat=n=4:v=1:a=0;[4][1:a][5]concat=n=3:v=0:a=1;",
                "finalVideo.mp4"
        );
        processBuilder.inheritIO().start().waitFor();

OpenCV Get the Shape of the Matrix

copy iconCopydownload iconDownload
println(s"[${matrix.rows} ${matrix.cols()} ${matrix.channels()}]")

Can i select the only packages I used within my maven dependecies to export a runnable jar in eclipse?

copy iconCopydownload iconDownload
<dependency>
        <groupId>org.bytedeco</groupId>
        <artifactId>javacv-platform</artifactId>
        <version>${javacv-platform.version}</version>
        <exclusions>
            <exclusion>
                <groupId>javacv-platform</groupId>
                <artifactId>flycapture-platform</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javacv-platform</groupId>
                <artifactId>libfreenect-platform</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

Play an ARGB .mov video in a transparent JWindow

copy iconCopydownload iconDownload
grabber = new FFmpegFrameGrabber(splashPath);
grabber.setPixelFormat(avutil.AV_PIX_FMT_ARGB);
grabber.start();

SQL syntax error in unit tests, after upgrade from Spring Boot 1.5.21 to 2.3.4

copy iconCopydownload iconDownload
spring:
  ...
flyway:
  enabled: false
spring:
  ...
  flyway:
    enabled: false
-----------------------
spring:
  ...
flyway:
  enabled: false
spring:
  ...
  flyway:
    enabled: false

Java open CV hangs on VideoCapture for file if openCV is loaded with nu.pattern.OpenCV.loadShared();

copy iconCopydownload iconDownload
 <dependency>
    <groupId>org.openpnp</groupId>
    <artifactId>opencv</artifactId>
    <version>3.2.0-1</version>
</dependency>
static {
        //System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        System.load("D:\\Downloads\\opencv\\build\\java\\x64\\opencv_java2411.dll");
        System.load("D:\\Downloads\\opencv\\build\\x64\\vc12\\bin\\opencv_ffmpeg2411_64.dll");     
    }
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>opencv</artifactId>
        <version>2.4.11-0.11</version>
    </dependency>
    <dependency>
        <groupId>org.openpnp</groupId>
        <artifactId>opencv</artifactId>
        <version>2.4.11-2</version>
    </dependency>
-----------------------
 <dependency>
    <groupId>org.openpnp</groupId>
    <artifactId>opencv</artifactId>
    <version>3.2.0-1</version>
</dependency>
static {
        //System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        System.load("D:\\Downloads\\opencv\\build\\java\\x64\\opencv_java2411.dll");
        System.load("D:\\Downloads\\opencv\\build\\x64\\vc12\\bin\\opencv_ffmpeg2411_64.dll");     
    }
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>opencv</artifactId>
        <version>2.4.11-0.11</version>
    </dependency>
    <dependency>
        <groupId>org.openpnp</groupId>
        <artifactId>opencv</artifactId>
        <version>2.4.11-2</version>
    </dependency>
-----------------------
 <dependency>
    <groupId>org.openpnp</groupId>
    <artifactId>opencv</artifactId>
    <version>3.2.0-1</version>
</dependency>
static {
        //System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        System.load("D:\\Downloads\\opencv\\build\\java\\x64\\opencv_java2411.dll");
        System.load("D:\\Downloads\\opencv\\build\\x64\\vc12\\bin\\opencv_ffmpeg2411_64.dll");     
    }
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>opencv</artifactId>
        <version>2.4.11-0.11</version>
    </dependency>
    <dependency>
        <groupId>org.openpnp</groupId>
        <artifactId>opencv</artifactId>
        <version>2.4.11-2</version>
    </dependency>

java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat(IIILjava/nio/ByteBuffer;)J

copy iconCopydownload iconDownload
static {

    String libraryPath = System.getProperty("opencv.path");

    System.load(libraryPath);

}

How to display OpenCV webcam capture frame in JavaFX app

copy iconCopydownload iconDownload
import java.nio.ByteBuffer

import javafx.scene.image._
import org.bytedeco.javacv.Frame
import org.bytedeco.opencv.global.opencv_imgproc._
import org.bytedeco.opencv.opencv_core.Mat

val videoView: ImageView = ImageView()
val grabber: OpenCVFrameGrabber = OpenCVFrameGrabber(0)
grabber.start()

// Fire off a thread to grab frames while the camera is active
// Each frame will ber passed to the updateView method below
// ... timer/thread omitted for brevity

val javaCVMat = Mat()

/** create buffer only once saves much time! */
val buffer: ByteBuffer = javaCVMat.createBuffer()

val formatByte: WritablePixelFormat<ByteBuffer> = PixelFormat.getByteBgraPreInstance()

fun updateView(frame: Frame): Unit = {
  val w = frame.imageWidth()
  val h = frame.imageHeight()

  val mat = javaCVConv.convert(frame)
  cvtColor(mat, javaCVMat, COLOR_BGR2BGRA)

  val pb = PixelBuffer(w, h, buffer, formatByte)
  val wi = WritableImage(pb)
  videoView.setImage(wi)
}

-----------------------
import javafx.application.Application
import javafx.embed.swing.SwingFXUtils
import javafx.scene.Scene
import javafx.scene.image.ImageView
import javafx.scene.image.WritableImage
import javafx.scene.layout.VBox
import javafx.stage.Stage
import org.bytedeco.javacv.Frame
import org.bytedeco.javacv.Java2DFrameConverter
import org.bytedeco.javacv.OpenCVFrameGrabber
import java.awt.image.BufferedImage
import java.util.concurrent.Executors

class StackOverflow : Application() {
    private val java2DFrameConverter: Java2DFrameConverter = Java2DFrameConverter()

    companion object {
        @JvmStatic
        fun main(args: Array<String>) {
            launch(StackOverflow::class.java)
        }
    }

    override fun start(primaryStage: Stage) {
        val grabber: OpenCVFrameGrabber = OpenCVFrameGrabber(0)
        grabber.start()

        val imageView: ImageView = ImageView()

        Executors.newSingleThreadExecutor().execute {
            while (true) {
                val frame = grabber.grabFrame()
                imageView.image = frameToImage(frame)
            }
        }

        val scene: Scene = Scene(VBox(imageView), 800.0, 800.0)
        primaryStage.scene = scene
        primaryStage.show()
    }

    private fun frameToImage(frame: Frame): WritableImage {
        val bufferedImage: BufferedImage = java2DFrameConverter.getBufferedImage(frame)
        return SwingFXUtils.toFXImage(bufferedImage, null)
    }
}

JavaCV FFmpegFrameGrabber &amp; Java2DFrameConverter creating weird looking image

copy iconCopydownload iconDownload
bi = new Java2DFrameConverter().convert(frame);
Java2DFrameConverter.copy(frame, bi);
new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
-----------------------
bi = new Java2DFrameConverter().convert(frame);
Java2DFrameConverter.copy(frame, bi);
new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
-----------------------
bi = new Java2DFrameConverter().convert(frame);
Java2DFrameConverter.copy(frame, bi);
new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);

zip file too large aws lambda java gradle

copy iconCopydownload iconDownload
into('lib') {
    from configurations.runtimeClasspath
    exclude("**windows**") // example, untested.
}

Community Discussions

Trending Discussions on javacv
  • Create a video form images and videos and add audio to it programatically | Java, Python, ffmpeg
  • How do I successfully run JavaCV code example (JavaFxPlayVideoAndAudio.java)
  • OpenCV Get the Shape of the Matrix
  • Can i select the only packages I used within my maven dependecies to export a runnable jar in eclipse?
  • Play an ARGB .mov video in a transparent JWindow
  • Add JavaCV as a dependency, to run on a Raspberry PI?
  • java.lang.NoSuchMethodError: okhttp3.internal.Platform.log AND Exception in thread &quot;Okhttp Dispatcher&quot; java.lang.NoSuchFieldError: INSTANCE
  • SQL syntax error in unit tests, after upgrade from Spring Boot 1.5.21 to 2.3.4
  • Java open CV hangs on VideoCapture for file if openCV is loaded with nu.pattern.OpenCV.loadShared();
  • java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat(IIILjava/nio/ByteBuffer;)J
Trending Discussions on javacv

QUESTION

Create a video form images and videos and add audio to it programatically | Java, Python, ffmpeg

Asked 2022-Feb-17 at 20:07

I want to create a new video (finalVideo.mp4) with:

  1. 3 image files image1.jpg, image2.jpg, image3.jpg, each image to be seen for 4 seconds
  2. 1 video file (video1.mp4), lasts for about 30 seconds with a frame rate of 30fps
  3. 1 audio file (audio1.mp3)

In the final video (finalVideo.mp4) I want the audio (audio1.mp3) to play only when the images are present and the video's (video1.mp4) audio when the video is present.

For example: The final video (finalVideo.mp4) contains image1.jpg, video1.mp4, image2.jpg and image3.jpg (in order). The audio (audio1.mp3) should play for the first 4 seconds, then the video's (video1.mp4) audio for the next 30 seconds and then the audio (audio1.mp3) for the next 8 (4*2) seconds.

Please let me know how to do this programmatically. I was hoping to figure this out using Java (JavaCV) or Python (OpenCV). But there is no programming language restriction as such, the answer can be in any language.


EDIT 1

Here is my attempt at making this work:

String ffmpeg = Loader.load(org.bytedeco.ffmpeg.ffmpeg.class);
        ProcessBuilder processBuilder = new ProcessBuilder(
                ffmpeg,
                "-loop", "1",
                "-framerate", "30",
                "-t", "4",
                "-i", "image1.jpg",
                "-i", "video1.mp4",
                "-loop", "1",
                "-framerate", "30",
                "-t", "4",
                "-i", "image2.jpg",
                "-loop", "1",
                "-framerate", "30",
                "-t", "4",
                "-i", "image3.jpg",
                "-filter_complex", "[0][1][2][3]concat=n=4:v=1:a=0",
                "finalVideo.mp4"
        );
        processBuilder.inheritIO().start().waitFor();

The above code only solves the video creation part without audio. Please let me know how to add audio to this video as stated above.

ANSWER

Answered 2022-Feb-17 at 20:07

You can do the same with the audio, use -ss and -t input options to control where to clip it.

String ffmpeg = Loader.load(org.bytedeco.ffmpeg.ffmpeg.class);
        ProcessBuilder processBuilder = new ProcessBuilder(
                ffmpeg,
                "-loop", "1",
                "-framerate", "30",
                "-t", "4",
                "-i", "image1.jpg",
                "-i", "video1.mp4",
                "-loop", "1",
                "-framerate", "30",
                "-t", "4",
                "-i", "image2.jpg",
                "-loop", "1",
                "-framerate", "30",
                "-t", "4",
                "-i", "image3.jpg",
                "-t" 4, "-i", "audio1.mp3",
                "-ss" 4, "-t", 8, "audio1.mp3",
                "-filter_complex", 
                "[0][1:v][2][[3]concat=n=4:v=1:a=0;[4][1:a][5]concat=n=3:v=0:a=1;",
                "finalVideo.mp4"
        );
        processBuilder.inheritIO().start().waitFor();

(not 100% if you can use the same input file twice, but this should work.)

Source https://stackoverflow.com/questions/71162972

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install javacv

Simply put all the desired JAR files (opencv*.jar, ffmpeg*.jar, etc.), in addition to javacpp.jar and javacv.jar, somewhere in your class path. Here are some more specific instructions for common cases:.
In the Projects window, right-click the Libraries node of your project, and select "Add JAR/Folder…​".
Locate the JAR files, select them, and click OK.
Navigate to Project > Properties > Java Build Path > Libraries and click "Add External JARs…​".
Locate the JAR files, select them, and click OK.
Follow the instructions on this page: http://developer.android.com/training/basics/firstapp/
Copy all the JAR files into the app/libs subdirectory.
Navigate to File > Project Structure > app > Dependencies, click +, and select "2 File dependency".
Select all the JAR files from the libs subdirectory.
[OpenCV documentation](http://docs.opencv.org/master/)
[FFmpeg documentation](http://ffmpeg.org/doxygen/trunk/)
If the binary files available above are not enough for your needs, you might need to rebuild them from the source code. To this end, the project files were created for:. Once installed, simply call the usual mvn install command for JavaCPP, its Presets, and JavaCV. By default, no other dependencies than a C++ compiler for JavaCPP are required. Please refer to the comments inside the pom.xml files for further details.
Maven 3.x http://maven.apache.org/download.html
JavaCPP 1.5.6 https://github.com/bytedeco/javacpp
JavaCPP Presets 1.5.6 https://github.com/bytedeco/javacpp-presets
http://bytedeco.org/builds/

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Share this Page

share link
Compare Computer Vision Libraries with Highest Support
Compare Computer Vision Libraries with Highest Security
Compare Computer Vision Libraries with Permissive License
Compare Computer Vision Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.