Hi Laurent,
are you rendering the camera yourself or do you let the Wikitude SDK render it?
How do you plan to set the focus area in your camera implementation?
Best Regards,
Alex
Hi Alex,
I let the SDK render the camera frame itself (pretty close to simpleInputPlugin sample)
I set the focus area in my implementation of wikitudeCamera.java, using camera1 api. In my plugin I call getTargetPositionIncameraFrame (in update callback), and give this coordinates to my camera class.
I tried to draw the rect returned by this api on the screen but as the resolutions don't match, I'm forced to convert the rect into a 1280x720 area, but the rect dosn't follow the target very well when its seen with angles or when moving closer to the target.
Please see attached video. (the purple rect is the targetPositionInCameraFrame)
Regards,
Laurent
Hi Laurent,
what you need to consider when calculating the position on the screen is that the parts of the camera frame are not visible. This is because we scale the camera frame to fit the view. In the case of a 4:3 camera frame being displayed on a 16:9 view, the complete width of the frame is visible but part of the height is not visible.
Best Regards,
Alex
Hi Laurent,
please take a look at this pseudo-code which could work for your case.
targetRect // assume 200x100 rect in the center x = 320 y = 240 w = 200 h = 100 displayRatio = displayWidth / displayHeight // assume 1920x1080 -> 1.77777 device in orientation landscape frameRatio = frameWidth / frameHeight // assume 640x480 -> 1.33333 if displayRatio > frameRatio scaledDisplayHeight = displayWidth / frameRatio // -> 1920 / 1.3333 = 1440 scale = displayWidth / frameWidth // -> 1920 / 640 = 3 diff = (scalescaledDisplayHeight - displayHeight) / 2 // -> (1440-1080) / 2 = 180 this is the height of the part that was cut off on both sides x = targetRect.origin.x * scale // -> 320 * 3 = 960 y = targetRect.origin.y * scale - diff // -> 240 * 3 - 180 = 540 w = targetRect.size.width * scale // -> 200 * 3 = 600 h = targetRect.size.height * scale // -> 100 * 3 = 300 scaledTargetRect({x,y},{w,h})
It scales the rectangle you get by getTargetPositionIncameraFrame up to the display size.
Best Regards,
Alex
Regards,
Laurent
Hi Laurent,
which issue did you find on iOS? The issue with the 720p camera or the one fixed with the pseudo-code?
The 720p issue was not platform specific and should be fixed.
For the other issue you will still have to apply the same code as you did in android.
Best Regards,
Alex
Hi Laurent,
please try to use the pre-release version of the Wikitude SDK 7.1. It can be downloaded in the download section under the beta category.
Best Regards,
Alex
Laurent Latour
Hi,
I'm using the SDK 6.1, with an inputPlugin on android.
We need to get the exact position of the target in the camera frame, in order to autofocus the camera in a special area of the target.
I know there's a bug in this release about using it with a 720p resolution, (see post https://support.wikitude.com/support/discussions/topics/5000083211) but I still have a problem with this api:
- When the SDK is configured to use 640x480 camera frames (so 4:3 format), and the camera preview size is 640x480 (like in your samples), the viewfinder is displayed fullscreen (so in a 16:9 format). I can't figure out how to convert the values returned by getTargetPositionInCameraFrame() from a 4:3 frame to a 16:9 view..
I can't find any documentation about this on your website.. could you explain how it is supposed to work ?
Thanks,
Laurent