i'm new to opencv and use opencv3
.I'm trying to detect circles using hough-transform .i have this code which read image from a file and detect circles then write it to a file.this works fine .here is the original image and here is the detected one.
but i want to detect circles in a buffered image .so i used a method to convert buffered image to Mat object .then what happened is circle detection failed and image has been resized .also brightness has reduce too much.this is failed one.
here is the code i used to convert buffered image to mat ( taken from the stackoverflow answer)
public Mat bufferedImageToMat(BufferedImage bi) {
byte[] pixels = ((DataBufferByte) bi.getRaster().getDataBuffer()).getData();
Mat mat = new Mat(bi.getWidth(), bi.getHeight(), CvType.CV_8UC3);
mat.put(0, 0, pixels);
return mat;
}
i think problem is in above method.
this is code line 47
and 48
.
Mat source = Imgcodecs.imread(circleimage, Imgcodecs.CV_LOAD_IMAGE_COLOR);
//Mat source = bufferedImageToMat(bi);
if i use 1st one(directly read from image) code works .but if i use 2nd one circle detection fail.
can you see a problem in this method ? thanks