google-ar / codelab-augmented-images-intro

Apache License 2.0
19 stars 19 forks source link

Change augmented image tracking state #11

Closed Wilfred-Yang closed 3 years ago

Wilfred-Yang commented 3 years ago

Hi, I want to make some changes about this function: https://github.com/googlecodelabs/arcore-augmentedimage-intro/blob/master/arcore-android-sdk-1.18.1/samples/augmented_image_java/app/src/main/java/com/google/ar/core/examples/java/augmentedimage/AugmentedImageActivity.java#L304

  1. I want to change the "Tracking State" of augmented image to "Paused" when the tracking method is "LAST_KNOWN_POSE", because I want to re-detect and re-draw again when image is out of camera. I don't want the code to remember the position. How to change the "Tracking State"?

  2. Is it okay to re-detect and re-draw again when changing "Tracking State" to "STOPPED"? I'm not clear about the document of ARcore on public static final TrackingState STOPPED from this link: https://developers.google.com/ar/reference/java/com/google/ar/core/TrackingState

Thank you for your replying!

kai-dream commented 3 years ago

No, there's no way to change the image's TrackingState. You can implement this logic inside the "case TRACKING" section.

Stopped means the "current detected image" is no longer tracked. But if you move the device or image so that it re-enters the view, it will be re-detected.

Wilfred-Yang commented 3 years ago

Thank you for your hint! @kai-dream
I have successfully made it work!

I have other questions to ask you, too:

  1. Is is possible to make .obj file touchable to show a pop-up view after the .obj file shows on the screen? If not, how about changing .obj file to other type of files such as .jpg or .png file?

  2. I'm curious about those magic numbers you set for augmented images in draw function!

such as maze_edge_size: https://github.com/googlecodelabs/arcore-augmentedimage-intro/blob/master/arcore-android-sdk-1.18.1/samples/augmented_image_java/app/src/main/java/com/google/ar/core/examples/java/augmentedimage/rendering/AugmentedImageRenderer.java#L69

and -251.3f, 0.0f, 129.0f in Pose.makeTranslation: https://github.com/googlecodelabs/arcore-augmentedimage-intro/blob/master/arcore-android-sdk-1.18.1/samples/augmented_image_java/app/src/main/java/com/google/ar/core/examples/java/augmentedimage/rendering/AugmentedImageRenderer.java#L83

How do you adjust the magic number to make the GreenMaze attached on images? Do you have any formula to follow? Because I will change the .obj file in the future. I guess the magic numbers of each .obj file is different Thank you for your reply as always!

kai-dream commented 3 years ago
  1. Is is possible to make .obj file touchable to show a pop-up view after the .obj file shows on the screen? If not, how about changing .obj file to other type of files such as .jpg or .png file?

I'm not sure I understand the "touchable" feature. Are you saying to allow user to click on the object? If so that is a Computer graphics question, and there're several existing solutions to workaround that. Change .obj to .jpg or .png, I am not sure I quite understand what do you want to achieve with this too. .ojb file is a 3d asset file, .jpg and .png are 2D image files, they are very different from each other.

  1. Those magic numbers are the size of the actual maze in its obj file. You can open the maze .obj file using a text editor to calculate its size (using this formular: max(x) - min(x) = size (x)). This obj file is not properly adjusted, it's center is not at (0, 0, 0), what's why I need to make a adjustment using (-251.3, 0.0, 129.0), this is not necessary if your .obj file is centered at (0, 0, 0).
Wilfred-Yang commented 3 years ago
  1. Yes! I want to allow user to click the object. After clicking the object, it will show some information about the image which rendered the object. Such as information about Earth in the sample code. What should I do if I want to allow user to click the 3D asset files?
    How about rendering 2D images files and allow users to click them? Could you give me some suggestions on these two different files, respectively?

  2. I try to read the text of *.obj file. There are some different types of data in the file: v, vt, vn, f... Should I just focus on the coordinate x of type v to calculate the size?
    How do you calculate the center? By any other software?

  3. I try to replace the maze obj file other obj file. However, the color of file is so weird. I try to replace .png with .mtl file in this line:

https://github.com/googlecodelabs/arcore-augmentedimage-intro/blob/master/arcore-android-sdk-1.18.1/samples/augmented_image_java/app/src/main/java/com/google/ar/core/examples/java/augmentedimage/rendering/AugmentedImageRenderer.java#L50

But it failed, how to do adjust the code to get the original color of *.obj file?

I am very grateful if you have free time to help me figure out my questions!

kai-dream commented 3 years ago

Hi,

  1. The question of selecting an object is itself a large question, that is out of the scope of ARCore.

Common techniques are

Rendering images won't going to help with selection unfortunately, because we are in 3D. Unless you are using Sceneform 1.16, or other Rendering library that provides UI controls with HitTest capability.

  1. You can find *obj file format here https://en.wikipedia.org/wiki/Wavefront_.obj_file#:~:text=OBJ%20(or%20.&text=The%20OBJ%20file%20format%20is,of%20vertices%2C%20and%20texture%20vertices.

  2. I think your question are mostly on rendering, which is a much bigger area than ARCore. Let's only discuss ARCore AugmentedImage related questions here.

Wilfred-Yang commented 3 years ago

Thank you for giving further information! I'm sorry that I ask too many unrelated questions. I will think about other solutions to solve my problem. Thank you so much!