My application uses Google ML to detect objects by drawing rectangles (BoundingBox) around the object it detects. However, this is what it ends up looking like. The problem is that the rectangle is drawn above the object it's suppose to be drawn around. It's come to my attention that the focus is on the code and not on the library.
I've built this application using this CameraX documentation to build the camera stream preview from my device camera. I then used this Google ML documentation to get the application to build and track objects. However, it's come to my attention that I'm drawing the rectangles wrong, and I wish to know how exactly I can resolve that. I will provide the code for my DrawGraphic.java class and my MainActivity.java class. Any further information needed to supplement the question can be provided upon request!
Here is the DrawGraphic.java class that draws the rectangle;
I can't give you an exact answer, but in general, GUI systems work by a set of rectangular (viewport) areas. Often the co-ordinates of an inner area are relative to the area that contains it, not to the absolute screen rectangle that contains them all. So you might start with that approach.
Swing has a co-ordinate translation/rotation/scaling service that often applies to stuff like this.
Science is the process of replacing what we "know" with what is TRUE. Politics, alas, often prefers to be the opposite.
@Norm Radder, Line 123 of the following code is where the Rect is called and created. I was originally only going to put in that method only. However, I find that including everything first and isolating the root of the problem later can help. So here it is. Also, since you said the x values are ok, and y values aren't looking so good, how would I fix that?