Ask Your Question

Dimebag's profile - activity

2019-09-29 01:52:37 -0600 received badge  Notable Question (source)
2018-09-05 03:23:52 -0600 received badge  Popular Question (source)
2016-06-23 04:58:36 -0600 asked a question Descriptors and opponent-descriptors

I am trying to understand descriptors in visual recognition and to my understanding, there are 2 main classes: patch descriptors like SIFT and SURF, and binary descriptors like ORB and AKAZE. I have been reading this blog as it is the only simply-explained source I have found, along with other google results. So patch descriptors compute histograms (which rely on colors too, i.e. RGB) while binary descriptors only look at intensity (so grayscale, meaning colors, as in RGB, are irrelevant). Is this correct?

It seems like using 3 channels (SIFT) as opposed to 1 (ORB) would be much better in finding distinctive keypoints, with no regards to the speed of doing so. Then how comes ORB/AKAZE (are stated to) outperform SIFT?

Also, this implies that the opponent-descriptors use the opponent colors; so how can an opponent-binary descriptor exist? It simply inverts the gray 'color'? Does this provide any improvement in practice? Are the implementations available in openCV 3.1?

2016-06-15 10:21:58 -0600 commented question Create unique feature for ORB

so in other words, try template matching(?). Yes, that's top of my list, though I feel bad abandoning everything i wrote for ORB. thx for the link!

2016-06-14 06:37:55 -0600 commented question Create unique feature for ORB

@LBerger I have edited my post; hope this answers your questions.

2016-06-13 08:27:56 -0600 asked a question Create unique feature for ORB

My goal is to correctly feature-recognize some specific simplistic logos in photos, having a total of 20 different possible logos. My attempts so far using ORB are not going so well so I am thinking of aiding the process by adding a unique feature to the logos which would (hopefully) always be detected and matched almost perfectly (very low distance). Note that I mean having new logos which would have this feature, such as the opposite-corner squares in a qr-code. My understanding is that that's the basis of QR-codes, barcodes, etc., i.e. a standard visual 'thing' that defines the space into which to recognize data. Of course, actually using a qr-code would be the simplest way but I cannot do that. In other words, I want to try and create my own visual 'code' to work with ORB.

Any tips on how to make this 1 feature?

EDIT. An example of one of the logos: examplelogo

To further clarify: the idea is for people to take a picture of some objects and the software can then identify these objects, given the objects have one of these 20 tags on them. I can slightly modify these tags, i.e. add this unique feature, but they need to look pretty much the same.

2016-06-02 04:30:46 -0600 received badge  Editor (source)
2016-06-01 09:29:20 -0600 commented question Image Recognition using edge detection?

@StevenPuttemans I do have my doubts on that, if you can please clarify for me: What if the logo on the book is skewed a bit? And about the size? I can't know beforehand how large the logo is going to be in the image. Also colors? Should all images be made binary then, assuming the logos are black & white?

2016-06-01 03:19:05 -0600 received badge  Enthusiast
2016-05-31 10:52:50 -0600 received badge  Scholar (source)
2016-05-31 10:52:31 -0600 asked a question Image Recognition using edge detection?

I am trying to implement some kind of logo recognition for books. My ultimate task is to take a picture of 4-5 of these logos on books and to be able to recognize them. The logos look like: example, and amount to around 20 different ones. As you can notice, they are fairly simplistic and my attempts to use feature (corner) recognition with ORB/AKAZE/others are not really working. I tried various parameters for: preprocessing the images (enhance contrast, gaussian blur), feature&descriptor extracting (except SIFT/SURF because of their license), selecting the best features (min-distance threshold, ratio test, top 10). Trying to make any of these work with findHomography with RANSAC is very inaccurate (can tweak things so that it works for a specific case but fails completely at others).

Looking at their results, it seems that the logos are just too simplistic and do not have any good defining features. The above methods still find good matches with keypoints that are completely unrelated to the logos (even though not many). I believe I need to change my approach and am thinking of the following:

  • implement a clustering algorithm (instead of findHomography) to group features together and stop at some max threshold when a new keypoint to-be-added is too far from the others //EDIT: I mean hierarchical clustering here
  • use hough transform for clustering as in the Lowe paper (though I do not yet understand how)
  • something else?

Any ideas I could try or comments regarding the above? Is there maybe some sort of image recognition using more details about shape, as opposed to corners? Or some kind of recognition using canny edges? Are Ridge- or blob- recognition good options to investigate?

2016-05-25 10:12:09 -0600 commented question Feature recognition: perspective transform

@Eduardo Thank you! I played around with the threshold and indeed, I got it to show a square, so the code is correct; it is obvious though that it's now 'overfitting' just for this particular image. I will try the ratio distance and perhaps other techniques I have found in a paper by Lowe, such as distance between closest neighbor to 2nd closest neighbor and/or clustering with Hough transform.

2016-05-24 04:22:51 -0600 asked a question Feature recognition: perspective transform

I have implemented the C++ code found here in Java. However, it does not seem to work as I am getting this instead of a nice green outline around the detected image. Can anyone point out where the problem is?

My code is as following (and it's not the most beautiful one because of the so many needed conversions):

Note I am doing this matching with multiple images and the best matching (and other things) is stored at index 'bestMatch'; so in the scene image (index 0), I am looking for the best image match stored at index 1 to n, with bestMatch deemed best based on shortest distance.

//get the best match and show the matching with the original picture
        Mat matOut = new Mat();
        MatOfDMatch finalMatchess = new MatOfDMatch();
        DMatch[] finalMatches = new DMatch[goodMatches[bestMatch].size()];  //goodMatches contains the matches with 3*min_dist as in the C++ code
        for (int x=0;x<goodMatches[bestMatch].size();x++) {
            finalMatches[x] = goodMatches[bestMatch].get(x);
        }
        finalMatchess.fromArray(finalMatches);
        Features2d.drawMatches(mats[bestMatch],keyPoints[bestMatch],mats[0],keyPoints[0],finalMatchess,matOut);

        // stored the indexes for the good matches
        int[] usedQueryIds = new int[goodMatches[bestMatch].size()];
        int[] usedTrainIds = new int[goodMatches[bestMatch].size()];
        for (int x=0;x<goodMatches[bestMatch].size();x++) {
            usedQueryIds[x] = goodMatches[bestMatch].get(x).queryIdx;
            usedTrainIds[x] = goodMatches[bestMatch].get(x).trainIdx;
        }

        //get the points used in the matching
        Point[] kpBox = new Point[goodMatches[bestMatch].size()];
        Point[] kpBox2 = new Point[goodMatches[bestMatch].size()];
        KeyPoint[] kpp = keyPoints[bestMatch].toArray();
        for (int q=0;q<kpBox.length;q++) {
            kpBox[q] = kpp[usedQueryIds[q]].pt;
            kpBox2[q] = kp[usedTrainIds[q]].pt;
        }
        MatOfPoint2f bla = new MatOfPoint2f();
        MatOfPoint2f bla2 = new MatOfPoint2f();
        bla.fromArray(kpBox);
        bla2.fromArray(kpBox2);

        Mat H = Calib3d.findHomography(bla,bla2,Calib3d.RANSAC,5.);

        //create the points at the corners 
        List<Point> corners = new ArrayList<Point>();
        corners.add(new Point(0,0));
        corners.add(new Point(mats[bestMatch].cols(),0));
        corners.add(new Point(mats[bestMatch].cols(),mats[bestMatch].rows()));
        corners.add(new Point(0,mats[bestMatch].rows()));
        List<Point> sceneCorners = new ArrayList<Point>();

        //conversions
        MatOfPoint2f cornersMat = new MatOfPoint2f();
        cornersMat.fromList(corners);
        MatOfPoint2f sceneCornersMat = new MatOfPoint2f();
        sceneCornersMat.fromList(sceneCorners);

        Core.perspectiveTransform(cornersMat,sceneCornersMat,H);

        Point[] list = sceneCornersMat.toArray();

        Log.d(TAG,list[0].x + ",," + list[0].y);    //HERE they are too close together, not even forming a square
        Log.d(TAG,list[1].x + ",," + list[1].y);
        Log.d(TAG,list[2].x + ",," + list[2].y);
        Log.d(TAG,list[3].x + ",," + list[3].y);

        sceneCornersMat.put(0,0, sceneCornersMat.get(0,0)[0] + mats[bestMatch].cols(),sceneCornersMat.get(0,0)[1]);
        sceneCornersMat.put(1,0, sceneCornersMat.get(1,0)[0] + mats[bestMatch].cols(),sceneCornersMat.get(1,0)[1]);
        sceneCornersMat.put(2,0, sceneCornersMat.get(2,0)[0] + mats[bestMatch].cols(),sceneCornersMat.get(2,0)[1]);
        sceneCornersMat.put(3,0, sceneCornersMat.get(3,0)[0] + mats[bestMatch].cols(),sceneCornersMat.get(3,0)[1]);

        Imgproc.line(matOut,new Point(sceneCornersMat.get(0,0)),new Point(sceneCornersMat.get(1,0)), new Scalar(0,255 ...
(more)
2016-04-29 11:40:31 -0600 answered a question Android openCV byte[] to mat to byte[]

Seems quite inefficient but it works for me (for now):

//get the camera parameters
Camera.Parameters parameters = camera.getParameters();
int width = parameters.getPreviewSize().width;
int height = parameters.getPreviewSize().height;

//convert the byte[] to Bitmap through YuvImage; 
//make sure the previewFormat is NV21 (I set it so somewhere before)
YuvImage yuv = new YuvImage(data, parameters.getPreviewFormat(), width, height, null);
ByteArrayOutputStream out = new ByteArrayOutputStream();
yuv.compressToJpeg(new Rect(0, 0, width, height), 70, out);
Bitmap bmp = BitmapFactory.decodeByteArray(out.toByteArray(), 0, out.size());

//convert Bitmap to Mat; note the bitmap config ARGB_8888 conversion that 
//allows you to use other image processing methods and still save at the end
Mat orig = new Mat();
bmp = bmp.copy(Bitmap.Config.ARGB_8888, true);
Utils.bitmapToMat(bmp, orig);

//here you do whatever you want with the Mat

//Mat to Bitmap to OutputStream to byte[] to File
Utils.matToBitmap(orig, bmp);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.JPEG, 70, stream);
byte[] bytes = stream.toByteArray();
File pictureFile = getOutputMediaFile();
try {
    FileOutputStream fos = new FileOutputStream(pictureFile);
    fos.write(bytes);
    fos.close();
} catch (IOException e) {
    e.printStackTrace();
}
2016-04-27 10:08:04 -0600 asked a question Android openCV byte[] to mat to byte[]

My goal is to add an overlay on the camera preview that will find book edges. For that, I override the onPreviewFrame where I do the following:

public void onPreviewFrame(byte[] data, Camera camera) {
    Camera.Parameters parameters = camera.getParameters();
    int width = parameters.getPreviewSize().width;
    int height = parameters.getPreviewSize().height;
    Mat mat = new Mat((int) (height*1.5), width, CvType.CV_8UC1);
    mat.put(0,0,data);
    byte[] bytes = new byte[(int) (height*width*1.5)];
    mat.get(0,0,bytes);

    if (!test) {        //to only do once
        File pictureFile = getOutputMediaFile();
        try {
            FileOutputStream fos = new FileOutputStream(pictureFile);
            fos.write(bytes);
            fos.close();
            Uri picUri = Uri.fromFile(pictureFile);
            updateGallery(picUri);
            test = true;
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

For now I simply want to take one of the previews and save it after the conversion to mat.

After spending countless hours getting the above to look right, the saved picture cannot be seen on my testing phone (LG Leon). I can't seem to find the issue. Am I mixing the height/width because I'm taking pictures in portrait mode? I tried switching them and still doesn't work. Where is the problem?