Ask Your Question

A.Nemati's profile - activity

2016-12-21 04:17:51 -0500 received badge  Enthusiast
2016-12-19 01:37:35 -0500 commented question Java library captures image with very slow rate [FPS]

thank you. but, please check with real camera, if you can. real camera has some delay. I tested this code on real camera and similar code with c++ on same camera.

2016-11-29 02:24:47 -0500 commented answer Opencv java vs C++ in video capture

Thus, what is "SUPPORT -> ASK A QUESTION" link in home page ? This link means, opencv's support department, will respond to questions.

2016-11-29 01:55:52 -0500 commented question Java library captures image with very slow rate [FPS]

I put my code by edit question.

2016-11-27 01:53:37 -0500 received badge  Organizer (source)
2016-11-27 01:42:28 -0500 asked a question Java library captures image with very slow rate [FPS]

I used opencv to capture image within my project which is written in Java and I used your java library to do so. Using this method, I can get 10 FPS only in 1280x720 resolution however when I capture image by your c++ library using the same camera, I can capture about 25 to 30 FPS with the same resolution, which is a huge and unbelievable difference.

What's the problem with the Java library and why it is so slower than the c++ library. Isn't it just a wrapper upon the native opencv or what ???

Please answer this question because our project have been stuck since this problem arised. I tried other wrapper libraries upon opencv also but unfortunately I got almost the same result.

Any hint or solution ???

This is my Code:

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.videoio.VideoCapture;
import org.opencv.videoio.Videoio;
import org.opencv.videoio.VideoWriter;

public class ConnectCamViaOpenCV {
    private VideoCapture videoCapture;
    private boolean isOpened;
    private boolean isSucceed;

    public ConnectCamViaOpenCV() {
        videoCapture = null;
        isOpened = false;
        isSucceed = false;

    public void grabImage(){
        Mat frame = new Mat();

        videoCapture = new VideoCapture(0);
        isOpened = videoCapture.isOpened();
        System.out.println("connected: " + isOpened());
        videoCapture.set(Videoio.CV_CAP_PROP_FRAME_WIDTH, 1280);
        videoCapture.set(Videoio.CV_CAP_PROP_FRAME_HEIGHT, 720);
        isSucceed = videoCapture.grab();
        System.out.println("started: " + String.valueOf(isSucceed));
        if ((!isOpened) || (!isSucceed))
        System.out.println("------- START GRAB -------");

        //Wait for camera starting
        while (true){
            if (!frame.empty())

        int frameNo = 0;
        long startSysMillis = System.currentTimeMillis();
        while (frameNo < 150){
        System.out.println(frameNo + " frames in " + (System.currentTimeMillis() - startSysMillis) + " millis");

        videoCapture.release(); // release device

        System.out.println('\n' + "Done");

    public static void main(String[] args) {
        ConnectCamViaOpenCV connectCamViaOpenCV = new ConnectCamViaOpenCV();

The result is:

connected: true
started: true
------- START GRAB -------
150 frames in 16905 millis

2016-11-27 01:17:34 -0500 received badge  Editor (source)
2016-11-27 01:11:40 -0500 answered a question Opencv java vs C++ in video capture

Any answer ?????? what is it ? What kind of support is this ?

I tried to contact you @Indira but I can not find any contact information regarding this similar issue from your profile, what did you do for solving this problem buddy ???

2016-11-22 03:02:56 -0500 commented question Opencv java vs C++ in video capture

I have this problem too. When i grab image from camera in 1280x720 size by c++, i take about 25fps. But by java, i can take only 9fps. This is very important for me to resolve rightly and quickly, low speed in java. thanks a lot. and I am waiting for a solution.

2016-11-22 02:45:46 -0500 received badge  Supporter (source)