meekys / cam_overlay

MIT License
7 stars 3 forks source link

overlay.png is forced rendered in perspective #18

Open Bishamon1987 opened 5 years ago

Bishamon1987 commented 5 years ago

Im not sure of my title is correct.

I made a overlay.png that's should be used full screen since my car dimensions are very wide my lines start from the sides instead of the bottom. It looks like cam overlay change the picture in dimensions. But I need it rendered full screen like the cam input itself.

Bishamon1987 commented 5 years ago

What it shows when turning on camera... IMG_20190808_204808

What it shows without camera feed... IMG_20190808_204533

How I want to show on screen (the guidelines are removable on the camera)...

New Project(3)

Bishamon1987 commented 5 years ago

Ok, so I found my solution.

cd ~
git clone https://github.com/meekys/cam_overlay.git
cd ~/cam_overlay 
git checkout cpp
cd cam_overlay/src/CamOverlay/src/
sudo nano Overlay.cpp

Then change this part

VERTEX_T Overlay::ImageQuad[4] =
{   // x,     y,     z,     u,    v
    {{-1.0f,  1.0f,  2.0f}, 0.0f, 1.0f}, // Top left
    {{-1.0f, -1.0f,  1.0f}, 0.0f, 0.0f}, // Bottom left
    {{ 1.0f,  1.0f,  2.0f}, 1.0f, 1.0f}, // Top right
    {{ 1.0f, -1.0f,  1.0f}, 1.0f, 0.0f}  // Bottom right
};

To this (the Z values should all be 1.0f)

VERTEX_T Overlay::ImageQuad[4] =
{   // x,     y,     z,     u,    v
    {{-1.0f,  1.0f,  1.0f}, 0.0f, 1.0f}, // Top left
    {{-1.0f, -1.0f,  1.0f}, 0.0f, 0.0f}, // Bottom left
    {{ 1.0f,  1.0f,  1.0f}, 1.0f, 1.0f}, // Top right
    {{ 1.0f, -1.0f,  1.0f}, 1.0f, 0.0f}  // Bottom right
};

The Z values give perspective to the rendered lines which are horizontal and vertical and give it depth.

meekys commented 5 years ago

@Bishamon1987 Yeah, you're correct. I force a perspective. I should probably put this into an option to allow people to opt-in or opt-out depending on their preferences. The semi-transparency looks awesome in that overlay btw :-)

Bishamon1987 commented 5 years ago

VERTEX_T Overlay::ImageQuad[4] = { // x, y, z, u, v {{-1.0f, 1.0f, 1.0f}, 0.0f, 1.0f}, // Top left {{-1.0f, -1.0f, 1.0f}, 0.0f, 0.0f}, // Bottom left {{ 1.0f, 1.0f, 1.0f}, 1.0f, 1.0f}, // Top right {{ 1.0f, -1.0f, 1.0f}, 1.0f, 0.0f} // Bottom right };

Btw just a question, what are these u and v values? are they the x and y of the videofeed?