This document provides instructions for an exercise on augmented reality using the Godot game engine and OpenCV library. Students are asked to set up an example project that uses OpenCV within Godot. They are also instructed to get familiar with transformations, input and the user interface in Godot by modifying an included demo. The final part defines the scalar product of vectors and asks students to calculate it for two given vectors, as well as the angle between the vectors.
This document provides instructions for an exercise on augmented reality using the Godot game engine and OpenCV library. Students are asked to set up an example project that uses OpenCV within Godot. They are also instructed to get familiar with transformations, input and the user interface in Godot by modifying an included demo. The final part defines the scalar product of vectors and asks students to calculate it for two given vectors, as well as the angle between the vectors.
This document provides instructions for an exercise on augmented reality using the Godot game engine and OpenCV library. Students are asked to set up an example project that uses OpenCV within Godot. They are also instructed to get familiar with transformations, input and the user interface in Godot by modifying an included demo. The final part defines the scalar product of vectors and asks students to calculate it for two given vectors, as well as the angle between the vectors.
This document provides instructions for an exercise on augmented reality using the Godot game engine and OpenCV library. Students are asked to set up an example project that uses OpenCV within Godot. They are also instructed to get familiar with transformations, input and the user interface in Godot by modifying an included demo. The final part defines the scalar product of vectors and asks students to calculate it for two given vectors, as well as the angle between the vectors.
TUM School of Computation, Information and Technology Exercise Sheet 1
Dr. Nicole Weber April 23, 2024 Dr. Sandro Weber
Augmented Reality
Exercise 1 – Setting things up
In this exercise, we will build upon the game engine Godot (3.5.3 LTS) and the computer vision library OpenCV (4.9.0). In order to use OpenCV within Godot, we need to use the GDNative API. As a first step, we will run an example project doing just that. What we need for the setup: A camera Godot 3.5.3 LTS at https://godotengine.org/ OpenCV 4.9.0 C++ matching your OS at https://opencv.org/get-started/ Get the “bouncy” example project from https://github.com/lukacu/bouncy Compiling the <bouncy-repo>/native/ part of the example project: o Edit the <bouncy-repo>/native/CMakeLists.txt to include the line SET(OpenCV_DIR <path-to-opencv>/opencv-4.9.0/build/x64/vc16/lib) right before the line FIND_PACKAGE(OpenCV REQUIRED) o Depending on your OS, follow the specific instructions in Moodle to compile the C++ code (not run but BUILD) Once you’re done with the platform specific compilation, run the project in Godot Understanding what’s happening: o Check the camera object in the Gameplay.gd script in combination with the <...>/native/wrapper.c file to see how calls are made from Godot to the native library o <...>/native/camera.cpp (especially the constructor) to see how OpenCV opens a camera feed and runs a thread reading new frames Exercise 2 – Getting familiar with Godot To get a little more familiar with Godot and how to do 3D transformations, input and UI pick the „3D Rotate Direct Constant Smooth“ Demo from the Project Asset Library and play around with it. Try changing a few things like direction of rotation, introducing a translation, reacting to other inputs or UI elements. Then try other demos as well and look at their code!
Exercise 3 – Scalar Product
a) What is the definition of a scalar product (dot product) of two vectors? 𝑎⃗ ∙ 𝑏⃗⃗ = b) Calculate the scalar product for 1 1 𝑎⃗ = (0) ; 𝑏⃗⃗ = (1) 1 0 c) Calculate the angle ξ between vectors a and b.