Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
syedafeef opened this issue Jan 12, 2021 · 5 comments

Comments

@syedafeef
Copy link

syedafeef commented Jan 12, 2021

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 syedafeef changed the title Function to pass bitmap or image to see if it has a aruco marker. Fix for implemetation, Function to pass bitmap or image to see if it has a aruco marker. Jan 12, 2021
@RivoLink
Copy link
Owner

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.

@syedafeef
Copy link
Author

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: afeefmaliki@gmail.com

@RivoLink
Copy link
Owner

RivoLink commented Feb 7, 2021

Hi,

Ok, I will do that for you.

@RivoLink
Copy link
Owner

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants