Ask Your Question

Karanbeer Kaur's profile - activity

2020-05-21 09:55:35 -0600 received badge  Popular Question (source)
2019-05-20 17:01:14 -0600 received badge  Famous Question (source)
2018-09-16 02:18:28 -0600 received badge  Notable Question (source)
2018-06-17 12:52:15 -0600 received badge  Popular Question (source)
2016-11-08 22:57:02 -0600 asked a question how to configure .dylib in gradle

I am using gradle build system. please share steps or screenshot to configure .dylib for gradle build system

2016-11-04 01:22:48 -0600 commented answer error Sizes of input arguments do not match while using Core.compare

I have 2 jpg files having same dimensions.  e.g. in first image I have a line and in second image there is no line. I want to create another image that will show there is a difference pointing to that line with circle or square. I tried 

  1. matcher.match(descriptors1, descriptors2 ,matches);
  2. findContours and then used matchShapes
  3. Core.compare and then Core.countNonZero

  4. compareHist

but not clear which one of them is the best match

Using them I am able to find the images are equal or different, but not able to create new image that points the difference. Could you please provide some methods or link where from I get some help to complete this task.

2016-11-03 03:06:51 -0600 commented answer error Sizes of input arguments do not match while using Core.compare

@break context is simple,I want to compare 2 images and then draw rectangle around the image difference. the only thing is I am new to opencv, if you will write theory only, It will be bit difficult for me to understand. It will be helpful if you can give some sample refrence

2016-11-03 02:50:40 -0600 received badge  Supporter (source)
2016-11-03 02:50:37 -0600 commented answer error Sizes of input arguments do not match while using Core.compare

@break It worked. but don't know logically its correct of not.

2016-11-03 02:37:04 -0600 commented answer error Sizes of input arguments do not match while using Core.compare

@break if the dimensions are different and still want to compare then what I need to do

2016-11-03 02:13:17 -0600 asked a question error Sizes of input arguments do not match while using Core.compare
I am trying below code to compare 2 images. 

   Mat img1 = Imgcodecs.imread(filename1, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
   Mat img2 = Imgcodecs.imread(filename2, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
   Mat result = new Mat();
    Core.compare(img1,img2,result,Core.CMP_NE);
    int val = Core.countNonZero(result);

    if(val == 0) {
        //
        System.out.println("Duplicate Image");
    } else {
        //Different Image
        System.out.println("Different Image");
    }

But getting below error

OpenCV Error: Sizes of input arguments do not match (The operation is neither 'array op array' (where arrays have the same size and the same type), nor 'array op scalar', nor 'scalar op array') in compare, file /tmp/opencv3-20161019-20369-7r0q5p/modules/core/src/arithm.cpp, line 1253
Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: /tmp/opencv3-20161019-20369-7r0q5p/modules/core/src/arithm.cpp:1253: error: (-209) The operation is neither 'array op array' (where arrays have the same size and the same type), nor 'array op scalar', nor 'scalar op array' in function compare
]
    at org.opencv.core.Core.compare_0(Native Method)
    at org.opencv.core.Core.compare(Core.java:1071)

Please suggest.

2016-11-03 01:19:44 -0600 asked a question How to process result of matchShapes to get list of non-matching objects

I want to get list of non-matching objects in 2 images. Below tis the code snippet I am writing

    Mat img1 = Imgcodecs.imread(filename1, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
    Mat img2 = Imgcodecs.imread(filename2, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
    ArrayList<MatOfPoint> contours1 = new ArrayList<MatOfPoint>();
    ArrayList<MatOfPoint> contours2 = new ArrayList<MatOfPoint>();
    Imgproc.findContours(img1, contours1, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);
    Imgproc.findContours(img2, contours2, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);

    System.out.println("contours1==" + contours1.size() + "contours2==" + contours2.size());
    for (MatOfPoint matOfPoint : contours1) {
        Mat image1 = matOfPoint.t();
        for (MatOfPoint matOfPoint2 : contours2) {
            Mat image2 = matOfPoint2.t();
            double matchValue = Imgproc.matchShapes(image1,image2,Imgproc.CV_CONTOURS_MATCH_I1,0);
            System.out.println("matchValue="+matchValue);
        }

    }

Below is the output:-

contours1==62contours2==42
matchValue=1.5655476914844257E-11
matchValue=0.0
matchValue=1.5655476914844257E-11
matchValue=1.5655476914844257E-11
matchValue=0.0
matchValue=1.5655476914844257E-11
matchValue=1.5655476914844257E-11
matchValue=2.4461765946171E-11
matchValue=2.3483215372266386E-11
matchValue=0.0
matchValue=0.0
matchValue=1.2230216839270724E-12
matchValue=1.2230216839270724E-12
matchValue=0.0
matchValue=0.0
matchValue=9.78328529299688E-13
matchValue=3.913980251013527E-12
matchValue=9.78328529299688E-13
matchValue=9.78328529299688E-13
matchValue=3.913980251013527E-12
matchValue=0.0
matchValue=3.913980251013527E-12
matchValue=0.0
matchValue=9.78328529299688E-13
matchValue=3.913980251013527E-12
matchValue=9.78328529299688E-13
matchValue=0.0
matchValue=9.78328529299688E-13
matchValue=9.78328529299688E-13
matchValue=0.0
matchValue=4.892308780313215E-12
matchValue=3.913758206408602E-12
matchValue=3.913758206408602E-12
matchValue=4.892308780313215E-12
matchValue=0.0
matchValue=0.06707455245189053
matchValue=1.0763168134531043E-11
matchValue=4.892308780313215E-12
matchValue=1.0763168134531043E-11
matchValue=1.0763168134531043E-11
matchValue=4.892308780313215E-12
matchValue=1.0763168134531043E-11
matchValue=1.0763168134531043E-11
matchValue=1.0763168134531043E-11
matchValue=1.859090659195317E-11
matchValue=1.0763168134531043E-11
matchValue=1.0763168134531043E-11
matchValue=1.467714838554457E-11
matchValue=1.5655476914844257E-11
matchValue=1.0763168134531043E-11
matchValue=1.0763168134531043E-11
matchValue=1.467714838554457E-11
matchValue=1.467714838554457E-11
matchValue=1.5900170069471642E-11
matchValue=1.5900170069471642E-11
matchValue=1.467714838554457E-11
matchValue=1.467714838554457E-11
matchValue=1.5655476914844257E-11
matchValue=1.0763168134531043E-11
matchValue=1.5655476914844257E-11
matchValue=1.5655476914844257E-11
matchValue=1.0763168134531043E-11
matchValue=1.467714838554457E-11
matchValue=1.0763168134531043E-11
matchValue=1.9569457165857784E-11
matchValue=1.467714838554457E-11
matchValue=0.06707455246656768
matchValue=1.0518474979903658E-11
matchValue=5.137001934940599E-12
matchValue=1.0518474979903658E-11
matchValue=1.0518474979903658E-11
matchValue=5.137001934940599E-12

How I can use this output to get non-matching object list

2016-11-03 00:10:09 -0600 received badge  Enthusiast
2016-11-02 01:20:33 -0600 received badge  Editor (source)
2016-11-02 01:19:57 -0600 asked a question How to compare contour 2 Objects are matching or not in images

I have two array of MatOfPoint and want to compare position of objects and how I can implement this , which method i have to to use to check object at position are same or not.

    ArrayList<MatOfPoint> contours1 = new ArrayList<MatOfPoint>();
    ArrayList<MatOfPoint> contours2 = new ArrayList<MatOfPoint>();
2016-10-31 22:14:17 -0600 commented question Draw Rectangle around objects which not matching

@gfx now I have two List of findContours. now how I can use these list to new Image mentioning by drawing rectangle around non-matching object.

Mat img1 = Imgcodecs.imread(filename1, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
Mat img2 = Imgcodecs.imread(filename2, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);


ArrayList<MatOfPoint> contoursImg1 = new ArrayList<MatOfPoint>();
ArrayList<MatOfPoint> contoursImg2 = new ArrayList<MatOfPoint>();
Imgproc.findContours(img1, contoursImg1, new Mat(), Imgproc.RETR_LIST,Imgproc.CHAIN_APPROX_SIMPLE);
Imgproc.findContours(img2, contoursImg2, new Mat(), Imgproc.RETR_LIST,Imgproc.CHAIN_APPROX_SIMPLE);

System.out.println("contours1=="+contoursImg1.size()+"contours2=="+contoursImg2.size());
2016-10-30 22:24:04 -0600 asked a question Unsupported format or combination of formats while contours

I am trying below code to get contours of images.

 // Load images to compare
    Mat img1 = Imgcodecs.imread(filename1, Imgcodecs.CV_LOAD_IMAGE_COLOR);
    Mat img2 = Imgcodecs.imread(filename2, Imgcodecs.CV_LOAD_IMAGE_COLOR);
    System.out.println(img1);

    ArrayList<MatOfPoint> contours = new ArrayList<MatOfPoint>();
    Imgproc.findContours(img1, contours, new Mat(), Imgproc.RETR_LIST,Imgproc.CHAIN_APPROX_SIMPLE);
    Imgproc.findContours(img2, contours, new Mat(), Imgproc.RETR_LIST,Imgproc.CHAIN_APPROX_SIMPLE);

    System.out.println("contours=="+contours.size());

But getting below error:-

OpenCV Error: Unsupported format or combination of formats ([Start]FindContours supports only CV_8UC1 images when mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only) in cvStartFindContours, file /tmp/opencv3-20161019-20369-7r0q5p/modules/imgproc/src/contours.cpp, line 219
Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: /tmp/opencv3-20161019-20369-7r0q5p/modules/imgproc/src/contours.cpp:219: error: (-210) [Start]FindContours supports only CV_8UC1 images when mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only in function cvStartFindContours
]
2016-10-27 06:12:25 -0600 commented question Draw Rectangle around objects which not matching

@berak can you please suggest how to compare images, get objects and then draw rectangle for which objects are not matching

2016-10-27 01:30:31 -0600 asked a question Draw Rectangle around objects which not matching

I am using below code snippet to compare two images.After compare, I want to draw rectangle around the object which are not matching.

     int retVal = 0;
     int notMactingCount = 0;
     long startTime = System.currentTimeMillis();

    // Load images to compare
    Mat img1 = Imgcodecs.imread(filename1, Imgcodecs.CV_LOAD_IMAGE_COLOR);
    Mat img2 = Imgcodecs.imread(filename2, Imgcodecs.CV_LOAD_IMAGE_COLOR);
    System.out.println(img1);

    // Declare key point of images
    MatOfKeyPoint keypoints1 = new MatOfKeyPoint();
    MatOfKeyPoint keypoints2 = new MatOfKeyPoint();
    Mat descriptors1 = new Mat();
    Mat descriptors2 = new Mat();

    // Definition of ORB key point detector and descriptor extractors
    FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB);
    DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.ORB);

    // Detect key points
    detector.detect(img1, keypoints1);
    detector.detect(img2, keypoints2);

    // Extract descriptors
    extractor.compute(img1, keypoints1, descriptors1);
    extractor.compute(img2, keypoints2, descriptors2);

    // Definition of descriptor matcher
    DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING ); 

    // Match points of two images
    MatOfDMatch matches = new MatOfDMatch();
    System.out.println("Type of Image1= " + descriptors1.type() + ", Type of Image2= " + descriptors2.type());
    System.out.println("Cols of Image1= " + descriptors1.cols() + ", Cols of Image2= " + descriptors2.cols());
    System.out.println("keypoints1 of Image1= " + keypoints1.cols() + ", keypoints2 of Image2= " + keypoints2.cols());


    // Visualize the matches and save the visualization.

    if (descriptors2.cols() == descriptors1.cols()) {
        matcher.match(descriptors1, descriptors2 ,matches);

        // Check matches of key points
        DMatch[] match = matches.toArray();
        double max_dist = 0; double min_dist = 100;

        for (int i = 0; i < descriptors1.rows(); i++) {
            double dist = match[i].distance;
            if( dist < min_dist ) min_dist = dist;
            if( dist > max_dist ) max_dist = dist;
        }
         System.out.println("max_dist=" + max_dist + ", min_dist=" + min_dist);

        // Extract good images (distances are under 10)
        for (int i = 0; i < descriptors1.rows(); i++) {
            if (match[i].distance <= 10) {
                retVal++;
            }else{
                notMactingCount++;
            }
        }
        System.out.println("matching count=" + retVal+" notMactingCount="+notMactingCount);
    }

Please share code snippet to draw rectangle around the object which are not matching or any link reference