Ask Your Question

hamza qureshi's profile - activity

2017-05-04 04:38:09 -0600 received badge  Organizer (source)
2017-05-04 04:23:15 -0600 received badge  Editor (source)
2017-05-04 04:15:32 -0600 asked a question Javacv Mat to Opencv Mat

I am converting Javacv mat to Opencv i am succeeded if i do in this manner .

while ((grabbedImage = converter.convert(grabber.grab())) != null) {

    Mat imgFrame2 = new Mat(grabbedImage.address());

    Mat imgFrame2Copy = new Mat();
    imgFrame2.copyTo(imgFrame2Copy);


     Imgproc.cvtColor(imgFrame2Copy, imgFrame2Copy, Imgproc.COLOR_BGR2GRAY, 0);

    Imgproc.GaussianBlur(imgFrame2Copy, imgFrame2Copy, new Size(5, 5), 0);

    Imgproc.resize(imgFrame2Copy, imgFrame2Copy, new Size(1000,500));

    opencv_core.Mat output = new opencv_core.Mat() {
        {
            address = imgFrame2Copy.getNativeObjAddr();
        }
    };


    Frame rotatedFrame = converter.convert(output);
    frame.showImage(rotatedFrame);

}

the above code works fine and there my system doesnot hang but when i try to Clone()

while ((grabbedImage = converter.convert(grabber.grab())) != null) { Mat imgFrame2 = new Mat(grabbedImage.address());

        Mat imgFrame1Copy=new Mat();
        imgFrame1.copyTo(imgFrame1Copy);

        Mat imgFrame2Copy = new Mat();
        imgFrame2.copyTo(imgFrame2Copy);


          Imgproc.cvtColor(imgFrame1Copy, imgFrame1Copy, Imgproc.COLOR_BGR2GRAY, 0);
          Imgproc.cvtColor(imgFrame2Copy, imgFrame2Copy, Imgproc.COLOR_BGR2GRAY, 0);

        Imgproc.GaussianBlur(imgFrame1Copy, imgFrame1Copy, new Size(5, 5), 0);
        Imgproc.GaussianBlur(imgFrame2Copy, imgFrame2Copy, new Size(5, 5), 0);

        Imgproc.resize(imgFrame1Copy, imgFrame1Copy, new Size(1000,500));
        Imgproc.resize(imgFrame2Copy, imgFrame2Copy, new Size(1000,500));

       Mat imgDifference =new Mat();
       Core.absdiff(imgFrame1Copy, imgFrame2Copy, imgDifference);


        opencv_core.Mat output = new opencv_core.Mat() {
            {
                address = imgDifference.getNativeObjAddr();
            }
        };


        Frame rotatedFrame = converter.convert(output);
        frame.showImage(rotatedFrame);

        // imgFrame1 = imgFrame2.clone();
        imgFrame2.copyTo(imgFrame1);

}

it freezes my system when i use img Frame1 I am unable to understand any one who can solve my problem ? , I also tried copyTo instead of clone() but still system freezes .

2017-05-02 07:50:11 -0600 asked a question Laptop hangs while converting javacv Mat to opencv Mat

I am converting Javacv mat to Opencv i am succeeded if i do in this manner .

while ((grabbedImage = converter.convert(grabber.grab())) != null) {

    Mat imgFrame2 = new Mat(grabbedImage.address());

    Mat imgFrame2Copy = new Mat();
    imgFrame2.copyTo(imgFrame2Copy);


     Imgproc.cvtColor(imgFrame2Copy, imgFrame2Copy, Imgproc.COLOR_BGR2GRAY, 0);

    Imgproc.GaussianBlur(imgFrame2Copy, imgFrame2Copy, new Size(5, 5), 0);

    Imgproc.resize(imgFrame2Copy, imgFrame2Copy, new Size(1000,500));

    opencv_core.Mat output = new opencv_core.Mat() {
        {
            address = imgFrame2Copy.getNativeObjAddr();
        }
    };


    Frame rotatedFrame = converter.convert(output);
    frame.showImage(rotatedFrame);

}

the above code works fine and there my system doesnot hang but when i try to Clone()

while ((grabbedImage = converter.convert(grabber.grab())) != null) { Mat imgFrame2 = new Mat(grabbedImage.address());

        Mat imgFrame1Copy=new Mat();
        imgFrame1.copyTo(imgFrame1Copy);

        Mat imgFrame2Copy = new Mat();
        imgFrame2.copyTo(imgFrame2Copy);


          Imgproc.cvtColor(imgFrame1Copy, imgFrame1Copy, Imgproc.COLOR_BGR2GRAY, 0);
          Imgproc.cvtColor(imgFrame2Copy, imgFrame2Copy, Imgproc.COLOR_BGR2GRAY, 0);

        Imgproc.GaussianBlur(imgFrame1Copy, imgFrame1Copy, new Size(5, 5), 0);
        Imgproc.GaussianBlur(imgFrame2Copy, imgFrame2Copy, new Size(5, 5), 0);

        Imgproc.resize(imgFrame1Copy, imgFrame1Copy, new Size(1000,500));
        Imgproc.resize(imgFrame2Copy, imgFrame2Copy, new Size(1000,500));

       Mat imgDifference =new Mat();
       Core.absdiff(imgFrame1Copy, imgFrame2Copy, imgDifference);


        opencv_core.Mat output = new opencv_core.Mat() {
            {
                address = imgDifference.getNativeObjAddr();
            }
        };


        Frame rotatedFrame = converter.convert(output);
        frame.showImage(rotatedFrame);

        // imgFrame1 = imgFrame2.clone();
        imgFrame2.copyTo(imgFrame1);

}

it freezes my system when i use img Frame1 I am unable to understand any one who can solve my problem ? , I also tried copyTo instead of clone() but still system freezes .