Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Crop Image using four points

I am trying to crop an image then be able to display the image. I have four points in two arrays and it would make a rectangle shape. I have a code that i think would do the job but it is giving an error. Here is the code i hope you can help me out. I am working with android and only with Java. I have looked at http://answers.opencv.org/question/996/crop-image/ but i am unsure how to convert that info over to Java

    int startX =locListX.get(0);
    int startY =locListY.get(0);
    Collections.sort(locListX);
    Collections.sort(locListY);
    int width=locListX.get(3)-locListX.get(0);
    int height=locListY.get(3)-locListY.get(0);
    Mat image = mFind;
    Rect rectCrop = new Rect(startX, startY, width, height);
    Mat imCrop=  new Mat(image,rectCrop); 
    Utils.matToBitmap(imCrop, bmp5);
    mGrayView.setImageBitmap(bmp5);