Jorkdekok1 / CAR-system-Neurophysiology

0 stars 0 forks source link

Moving Camera Based on Animal Position and Head Direction #9

Open Jorkdekok1 opened 5 months ago

Jorkdekok1 commented 5 months ago

I have interpolated and smoothened the trajectory (head position and nose position) of a trail of the novel object recognition task. After the smoothening I infer the head direction by creating a vector based on the head an nose position. After the data processing I use the generated csv file as input for the scripts in bonsai.

Image

Firstly, I generate a video based on the smoothened tracking after which i used the following script to use the video as a texture on the cylinder, while simultanously moving the camera position and heading. The eye of the perspective view refer to the location of head of the animal and target is the head direction (converted from polar to cartesian coordinates).

Image

The resulting output of the script looks like this.

https://github.com/Jorkdekok1/CAR-system-Neurophysiology/assets/126770475/90dc130f-cd73-45f8-a402-4a9f060d1281

In the video below I sampled the video and animal position and head direction 2 times slower.

https://github.com/Jorkdekok1/CAR-system-Neurophysiology/assets/126770475/7e964da0-a813-43c3-9565-145ce9a6097b

Jorkdekok1 commented 5 months ago

I found a problem with how the head direction angle is being proccesed when moving the camera. Basically, in perspective view there are two input, the eye position and the target vector. The target vector is an issue as it specifies the specific location where the camera is pointing towards. To illustrate, in the following video the eye position is 0,0 and the target vector get input form a range animation that goes from 0 to 360 degrees in 10 seconds and then calculated the correspoding vector. (you can see 0 degrees corresponds to the red square).

https://github.com/Jorkdekok1/CAR-system-Neurophysiology/assets/126770475/983acc2a-3eaa-4db9-bde9-3401cbc06e52

Now, the problem arises when the eye position changes. In the video below I changed the position to (0,0.7) and at the start and end of the video the camera is still pointed at the red square (or more specifically pointed toward the point 1,0 as that is specified by the target vector)

https://github.com/Jorkdekok1/CAR-system-Neurophysiology/assets/126770475/013945d4-96c8-46ba-8480-661240d4f62a

When I increase the lenght of the vector i.e. (1000000, 0) when the rotation is 0 then the camera seem to more accurately point towards the x-axis instead the red square. I will be looking into an analytical solution instead of using an approximation of an infinitely large vector).

https://github.com/Jorkdekok1/CAR-system-Neurophysiology/assets/126770475/158a7a59-bcf9-40f8-a269-54177b6ff189