vvvv / VL.OpenCV

A VL wrapper for OpenCVSharp
BSD 3-Clause "New" or "Revised" License
43 stars 15 forks source link

Renderer excepts with square images #55

Closed joreg closed 2 years ago

joreg commented 2 years ago

calculation of the imageID fails in case of square images, because -w + h always results in 0. ie there is no change from the initial 1/1 size to any other square size.

therefore this else-if case is never hit: https://github.com/vvvv/VL.OpenCV/blob/b8291d55867822261d48654d1dd46c1e10e28bcc/src/Renderer.cs#L145

and subsequently this line throws an exception: https://github.com/vvvv/VL.OpenCV/blob/b8291d55867822261d48654d1dd46c1e10e28bcc/src/Renderer.cs#L152

joreg commented 2 years ago

see also #54

ravazquez commented 2 years ago

Fixed in commit 35e18de. Awaiting release.

joreg commented 2 years ago

@ravazquez it seems to me this code is still fishy: 2 things:

what do you think?

ravazquez commented 2 years ago

@joreg

tebjan commented 2 years ago
  • I am not so familiar with bit-combine magic, I will just go for a string solution.

using strings is unfortunately a very bad idea, especially if this is used for change checks every frame... the string operation is a few hundred times more expensive than bit operations and it will allocate memory on every call.

a very simple way to combine two numbers is to multiply one with a factor of 10s, so for example

long sizeNumber = width * 100000 + height;

this will put the number of the width in front of the number with the height...

similar with bit shifts would be

long sizeNumber = (width << 16) | height;

this just moves the bits of width 16 places up and then merges it with the height bits.

ravazquez commented 2 years ago

Thanks for the pointer and the explanation @tebjan, I will try to implement this ASAP