Fix for implemetation, Function to pass bitmap or image to see if it has a aruco marker.
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.
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.
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]
Hi,
Ok, I will do that for you.
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;
}
I sent it to your email, I hope it will help you, and sorry for being late :)