Projection and distortion on slanted walls

422 views
Skip to first unread message

Auriane BUSSER

unread,
May 28, 2021, 10:30:53 AM5/28/21
to Bonsai Users
Hi all,

I am trying to recreate a set up similar to this one  (from  "Virtual Reality system for freely-moving rodents" preprint by  Nicholas A. Del Grosso et al.) with an overhead projector displaying a VR environment for mice in an arena, using BonVision.
The walls of the arena are slightly slanted in order to achieve a good projection.

I'm having trouble to find a good way to correct the perspective of the projection on the walls so the image doesn't get distorted from the animal's point of view. My best guess for now is that Mesh-mapping could do the trick, but I am not sure it can be used on non-curved surfaces. Or it might need to be modified in order to do so ...
Any ideas on how I could correct this projection or if using MeshMapping could work in that case ?

Thanks a lot.
Best,
Auriane.

img (2).jpg

Aman Saleem

unread,
May 29, 2021, 5:52:03 AM5/29/21
to Auriane BUSSER, Bonsai Users
Dear Auriane,

This is an interesting problem. Yes, I think MeshMapping is the solution, and it should also be fine to use for skewed flat displays. This page has some details of the process: https://bonvision.github.io/demos/demos_006_MeshMapping/

In practical terms for implementing a render sequence in BonVision, it is probably best to create 4 ViewWindow(s) for four DrawViewPort(s). 
The MeshMapping node usually goes at the end and you will probably need 4 independent mesh maps in your case. We have not done this before as we most often have run a meshmapping on a single display, and the process of meshmapping is going to be different. However, given that the mapping is a simple skew, the easiest option is probably to use an analytical solution to calculate the transformations. 

Best,
Aman


--
You received this message because you are subscribed to the Google Groups "Bonsai Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/57bf4a5e-0afb-4fa2-81b3-a5affd0255ddn%40googlegroups.com.


--
Aman Saleem
University College London
London, UK



Gonçalo Lopes

unread,
Jun 5, 2021, 7:26:55 PM6/5/21
to Aman Saleem, Auriane BUSSER, Bonsai Users
Hi Auriane,

This is a cool example for the new PerspectiveMapping operator, which will allow you to independently map the 4 walls on the arena using the projector. Basically this node allows you to remap and correct the perspective of the output render based on moving around the four corners of the viewport using the editor in the Destination property. Those corners uniquely define a perspective which should account for the slant on the projector viewports.

By defining four ViewWindow pipelines as Aman suggested, and filling in their world positions appropriately, you should be able to calibrate the perspective of the animal onto each of the 4 independent displays just as if they are normal screens. Once that is done, what is left is to make sure the pixels of each screen go into the correct physical place in the arena walls using PerspectiveMapping.

I'm including a short clip and an example workflow below (also attached):

image.png


video2021-06-06T00_25_30.gif

Word of warning, the workflow is not calibrated properly so don't expect it to be consistent, this will have to be figured out with the correct numbers for the specific setup.

Hope it helps.

dynamic-map.zip

Auriane BUSSER

unread,
Jun 8, 2021, 4:23:44 AM6/8/21
to Bonsai Users
Thank you Aman and Gonçalo, this worked perfectly !
Creating an analytical meshmapping was fine however the PerspectiveMapping node makes everything way more convenient.

Best,
Auriane.

Auriane BUSSER

unread,
Jul 7, 2021, 7:39:06 AM7/7/21
to Bonsai Users
Hi again !
After using the arena with flat slanted walls for a while, I am now trying to do the same with curved slanted walls using an arena shaped like the image below.
I've tried to adapt the workflow for flat slanted walls to this new arena, but I always struggle when it comes to display the mapping. I'm guessing the problem comes from the ViewWindow or the ViewPort but I couldn't figure it out on my own.




img3.jpg


First I tried to still use the CubeMap and simply switch the PerspectiveMapping node for MeshMapping ones, each MeshMapping node mapping a quarter of the arena.
When displaying one side of the cube at a time this seems to work fine, however, when displaying more than one, all of the ViewPorts are displayed with the same shape and orientation.
Am I missing a step in the definition of the display destination ?

workflow.jpg  display1.jpg  display2.jpg



I then tried something similar using PerspectiveView instead of CubeMapView and RenderCubeMap, but I run into the same problem.



Any suggestions on where that problem comes from and how to display a projection on these curved slanted walls ?

Thanks in advance !
Best,
Auriane.

Gonçalo Lopes

unread,
Jul 18, 2021, 7:22:13 AM7/18/21
to Auriane BUSSER, Bonsai Users
Hi Auriane,

Don't know if you have figured this out yet, but if I understand correctly how you are trying to approach this, I believe the easiest way would be to use the MeshMapping node combined with the PerspectiveMapping node (one after the other). This way you should be able to reuse the same transformation for the cylindrical section, but then individually projected to each "side" (quarter) of the cylinder.

If this doesn't work, can you please attach your current workflow so we can reproduce and tweak the perspective?
Hope this helps.

Auriane BUSSER

unread,
Aug 2, 2021, 8:47:31 AM8/2/21
to Bonsai Users
Hi Gonçalo,

Thank you for the suggestion it works indeed way better with both the MeshMapping and PerspectiveMapping combined.
However, I always end up with a cropped view of certain side, like the example below. I've tried changing all the window and mapping parameters but it is still cropped ...
Do you have any idea why this happens or what I might be doing wrong ?

Bonsai-crop-window.jpg

I've attached the workflow I use and all of the screen's meshmapping csv file.

Thank you,
Auriane.
Screen4-output.csv
Screen1-output.csv
Screen3-output.csv
Screen2-output.csv
Meshmap_cone2.bonsai

Gonçalo Lopes

unread,
Aug 22, 2021, 7:38:47 PM8/22/21
to Auriane BUSSER, Bonsai Users
Hi Auriane,

This happens because of a side-effect on the viewport of chaining the mesh mapping and perspective mapping together. It looks like you were trying to specify custom viewport coordinates in two of the DrawViewport nodes. It's not clear to me whether you really need to do this at all, but every time you do this and you need to apply viewport specific post-processing (like mesh mapping) you need to make sure the viewport is reset back to full screen, otherwise the post-processing effect will be applied in the last updated viewport.

You can use the UpdateViewportState operator to make this reset (also attached):

image.png

Hope this helps.

Meshmap_cone3.bonsai
Reply all
Reply to author
Forward
0 new messages