Ask Your Question

Vijay Nirmal's profile - activity

2017-10-20 06:06:52 -0600 commented question Second camera is not opening until the first camera is released

@LBerger After restarting my computer, my code works. I don't understand what is the problem but it works now. Thanks fo

2017-10-18 15:13:13 -0600 commented question Second camera is not opening until the first camera is released

@LBerger It is correct. In python, it is single & or I can use and. I have tested, capR.isOpened() returns false

2017-10-18 15:12:28 -0600 commented question Second camera is not opening until the first camera is released

@LBerger It is correct. In python, it is single & or I can use and

2017-10-18 15:09:46 -0600 commented question Second camera is not opening until the first camera is released

@LBerger It is correct. In python, it is single &

2017-10-18 13:47:54 -0600 commented question Second camera is not opening until the first camera is released

@LBerger Not at this moment but will use it in near future.

2017-10-18 13:47:11 -0600 edited question Second camera is not opening until the first camera is released

Second camera is not opening until the first camera is released I want to display the video inputs from two cameras at t

2017-10-18 13:46:40 -0600 commented question Second camera is not opening until the first camera is released

@LBerger Not at this moment but will use in near future.

2017-10-18 13:45:26 -0600 received badge  Editor (source)
2017-10-18 13:45:26 -0600 edited question Second camera is not opening until the first camera is released

Second camera is not opening until the first camera is released I want to display the video inputs from two cameras at t

2017-10-18 12:59:55 -0600 commented question Second camera is not opening until the first camera is released

@LBerger I have tried with one USB cam and a built-in webcam. same problem

2017-10-18 11:46:12 -0600 received badge  Organizer (source)
2017-10-18 11:44:43 -0600 asked a question Second camera is not opening until the first camera is released

Second camera is not opening until the first camera is released I want to display the video inputs from two cameras at t

2017-09-29 17:23:58 -0600 received badge  Student (source)
2017-09-29 14:37:50 -0600 marked best answer StereoBM doesn't give proper output

I want to find depth from stereo image. My code is working for one pair of an image but not working for another pair of an image.

Later, I want to convert video inputs from two cameras into a stereo output. I have tried that but that also have the same issue as the images (second pair of images) shown below.

I have tried it in with Java and Python and faced the same issue in both the languages.

Here is my java code

public static void main(String[] args)
{
    Mat left = Imgcodecs.imread("path", Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
    Mat right = Imgcodecs.imread("path", Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);

    Core.normalize(left, left, 0, 255, NORM_MINMAX, CvType.CV_8U);
    Core.normalize(right, right, 0, 255, NORM_MINMAX, CvType.CV_8U);

    StereoBM bm = StereoBM.create(16, 15);

    Mat disparity = new Mat();
    bm.compute(left, right, disparity);
    ImageProcessor.showResult(disparity);
    mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}

public static void showResult(Mat img)
{
    Imgproc.resize(img, img, new Size(640, 480));
    MatOfByte matOfByte = new MatOfByte();
    Imgcodecs.imencode(".jpg", img, matOfByte);
    byte[] byteArray = matOfByte.toArray();
    BufferedImage buffImage = null;
    try
    {
        InputStream in = new ByteArrayInputStream(byteArray);
        buffImage = ImageIO.read(in);
        JFrame frame = new JFrame();
        frame.getContentPane().add(new JLabel(new ImageIcon(buffImage)));
        frame.pack();
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setVisible(true);
    } catch (IOException e)
    {
        e.printStackTrace();
    }
}

How can I correct my code so that it will work for all images?

The below images gives expected output

image description image description image description

The below images gives incorrect output

image description image description image description

2017-09-27 01:47:00 -0600 asked a question StereoBM doesn't give proper output

StereoBM doesn't give proper output I want to find depth from stereo image. My code is working for one pair of an image