Aruco-Android icon indicating copy to clipboard operation
Aruco-Android copied to clipboard

Fix for implemetation, Function to pass bitmap or image to see if it has a aruco marker.

Open syedafeef opened this issue 5 years ago • 5 comments

Hello, I went through the app, the mechanism used and tried modifying it to take an image from files as input but the logic for camera integration is too complex. Can you help me with creating a function that takes a bitmap as input and tell me if it has an Aruco marker and function to mark it? Plus on a note, The application as a lot of unused class that makes it slow to load.

I have fixed the implementation issue and also added the camera permission on launch, if you want I can share the changes.

Thank you.

syedafeef avatar Jan 12 '21 13:01 syedafeef

Hi, sorry for being late :)

Yes, I will create this function for you, and I will notify you when I finish. About your implementations, you can create a Pull Request on branch master.

Thanks.

RivoLink avatar Jan 15 '21 15:01 RivoLink

Hey Rivo, I don't think I can create a pull request without access also please look into that function or interface to pass image as bitmap or from a file. My email is mentioned below Email: [email protected]

syedafeef avatar Feb 04 '21 09:02 syedafeef

Hi,

Ok, I will do that for you.

RivoLink avatar Feb 07 '21 18:02 RivoLink

Hi,

I have committed a new feature which implements the detection of markers inside a bitmap image.

This is the main function I used, you can find it in: https://github.com/RivoLink/Aruco-Android/blob/master/app/src/main/java/mg/rivolink/app/aruco/ImageActivity.java

private static Bitmap detectMarkers(Bitmap original){
	Bitmap bitmap = null;

	Mat rgba = new Mat();
	Utils.bitmapToMat(original,rgba);

	Mat rgb = new Mat();
	Imgproc.cvtColor(rgba,rgb,Imgproc.COLOR_RGBA2RGB);

	Mat gray = new Mat();
	Imgproc.cvtColor(rgba,gray,Imgproc.COLOR_RGBA2GRAY);

	MatOfInt ids=new MatOfInt();
	List<Mat> corners = new LinkedList<>();
	Dictionary dictionary = Aruco.getPredefinedDictionary(Aruco.DICT_6X6_50);
	DetectorParameters parameters = DetectorParameters.create();

	Aruco.detectMarkers(gray,dictionary,corners,ids,parameters);

	if(corners.size() > 0){
		Aruco.drawDetectedMarkers(rgb,corners,ids);

		Mat rvecs = new Mat();
		Mat tvecs = new Mat();

		Aruco.estimatePoseSingleMarkers(corners,0.04f,cameraMatrix,distCoeffs,rvecs,tvecs);
		for(int i=0;i<ids.toArray().length;i++){
			Aruco.drawAxis(rgb,cameraMatrix,distCoeffs,rvecs.row(i),tvecs.row(i),0.02f);
		}

		rvecs.release();
		tvecs.release();

		bitmap=Bitmap.createBitmap(rgb.width(),rgb.height(),Bitmap.Config.RGB_565);
		Utils.matToBitmap(rgb,bitmap);
	}

	rgba.release();
	rgb.release();
	gray.release();
	ids.release();

	corners.clear();

	return bitmap;
}

RivoLink avatar Feb 12 '21 21:02 RivoLink

I sent it to your email, I hope it will help you, and sorry for being late :)

RivoLink avatar Feb 12 '21 21:02 RivoLink