ShaharMS / Vision

Cross framework, cross platform computer vision for Haxe
MIT License
35 stars 5 forks source link

Skew images (WIP) #38

Closed Wither362 closed 1 year ago

Wither362 commented 1 year ago

Yes dude! I finally got the algorithm to skew images!

TODO:

ShaharMS commented 1 year ago

Nice! I'll take a look at that later, rn I'm trying to make CI send you a url of the images generated from your PRs. Then, you could add a test, and it would display there.

Wither362 commented 1 year ago

Nice! I'll take a look at that later, rn I'm trying to make CI send you a url of the images generated from your PRs. Then, you could add a test, and it would display there.

Thanks!

Wither362 commented 1 year ago

How do I move a pixel from coordinates (x, y) to coordinates (x2, y2)?

I need it to finish this…

I found two solutions:

ShaharMS commented 1 year ago

movePixel might already exist as copyPixel, but I'm not sure. A quick solution rn is to do setPixel(newX, newY, getPixel(oldX, oldY))

Wither362 commented 1 year ago

movePixel might already exist as copyPixel, but I'm not sure. A quick solution rn is to do setPixel(newX, newY, getPixel(oldX, oldY))

Isn't setPixel(x, y, color) to change the color of the specified pixel?

I want to move the pixel, but it might work also…

ShaharMS commented 1 year ago

movePixel might already exist as copyPixel, but I'm not sure. A quick solution rn is to do setPixel(newX, newY, getPixel(oldX, oldY))

Isn't setPixel(x, y, color) to change the color of the specified pixel?

I want to move the pixel, but it might work also…

by moving do you mean switching between the pixels? setPixel(..., getPIxel(...)) simply "duplicates" the pixel at the old position to the new one. did you mean something else?

ShaharMS commented 1 year ago

or maybe you mean moving the pixel at the old position to the new position, and resetting it's color to the default (0x00000000)

Wither362 commented 1 year ago

or maybe you mean moving the pixel at the old position to the new position, and resetting it's color to the default (0x00000000)

Yeah! That’s what I mean!

ShaharMS commented 1 year ago

ok! ill implement this as movePixel() and add an extra argument for the reset color:

movePixel(fromX, fromY, toX, toY, ?oldPixelColor)

ShaharMS commented 1 year ago

oh, that probably means implementing moveSafePixel and moveFloatingPixel

Wither362 commented 1 year ago

ok! ill implement this as movePixel() and add an extra argument for the reset color:

movePixel(fromX, fromY, toX, toY, ?oldPixelColor)

That sounds good! Maybe I can help you with the function code, but I’m not sure…

Wither362 commented 1 year ago

oh, that probably means implementing moveSafePixel and moveFloatingPixel

Yeah… 😅

ShaharMS commented 1 year ago

those shouldn't be hard to implement, just the same function but doesnt throw/gets different type params.

im also gonna implement moveUnsafePixel for that extra speeeed🚀

ShaharMS commented 1 year ago

implemented! merge the main branch to get these functions.

ShaharMS commented 1 year ago

there are 4 new functions:

Wither362 commented 1 year ago

there are 4 new functions:

  • movePixel() - behavior discussed above
  • moveSafePixel() - safe as above, but handles positions outside the bounds of the image
  • moveFloatingPixel() - allows using floats for pixel positions, blends colors if necessary.
  • moveUnsafePixel() - same as movePixel() but without error handling, always faster than movePixel() but errors may be vague

Thanks! I think I will use moveSafePixel() for better use

Wither362 commented 1 year ago

there are 4 new functions:

  • movePixel() - behavior discussed above
  • moveSafePixel() - safe as above, but handles positions outside the bounds of the image
  • moveFloatingPixel() - allows using floats for pixel positions, blends colors if necessary.
  • moveUnsafePixel() - same as movePixel() but without error handling, always faster than movePixel() but errors may be vague

It would help me if you could add moveFloatingSafePixel(), but I don’t really care about doing the skewFloat() function anyway…

ShaharMS commented 1 year ago

I think CI is failing because of the added rotate car in the image class, variables shouldn't be added like that since they have to be based somewhere in the abstract (for example, width is stored in the first couple of bytes)

ShaharMS commented 1 year ago

Another thing, if it isn't slow, I think floating pixel checks should be safe by default, since you need to be super careful otherwise

ShaharMS commented 1 year ago

A stack overflow error is also interesting 🤔

And the error message seems lacking. I should revisit this sometime.

ShaharMS commented 1 year ago

Also, I think you're implementation of rotation only works if rotate is a storable value, which isn't the case here since image is an abstract. I wonder how much turning image into a regular class will effect performance...

Wither362 commented 1 year ago

Ahh… so… what should I do?

Wither362 commented 1 year ago

I’m kinda new in using abstracts…

ShaharMS commented 1 year ago

I’m kinda new in using abstracts…

Sorry for late reply, abstracts are pretty well explained (I think) here: https://haxe.org/manual/types-abstract.html

Wither362 commented 1 year ago

I’m kinda new in using abstracts…

Sorry for late reply, abstracts are pretty well explained (I think) here: https://haxe.org/manual/types-abstract.html

Ok, thanks, so, I can’t use variables like I use them in classes…

About creating a new test

I think I’ll use addToScreen(), and I’ll copy one of the tests, so I’m not sure if it will work… but I’ll try

ShaharMS commented 1 year ago

Looking at this again, I don't think most of the functions mentioned in the first message are really needed. Another thing, this would be wayyy easier to implement if you don't try to create any custom properties on the image class. Simply an image skewing algorithm that rotates an image providing an image and angle is pretty much 90% of the work done, since it lays the foundation for other functions to be implemented

Wither362 commented 1 year ago

Looking at this again, I don't think most of the functions mentioned in the first message are really needed. Another thing, this would be wayyy easier to implement if you don't try to create any custom properties on the image class. Simply an image skewing algorithm that rotates an image providing an image and angle is pretty much 90% of the work done, since it lays the foundation for other functions to be implemented

Ah, ok then

Wither362 commented 1 year ago

Yey! It works!

Wither362 commented 1 year ago

It works!

At least the functions

Wither362 commented 1 year ago

@ShaharMS, can you also implement a moveFloatingSafePixel? It’s better when the rotation it’s almost exact, and not rounded like in Std.int()

ShaharMS commented 1 year ago

I'm pretty sure floating operations are safe by default on latest main

Wither362 commented 1 year ago

I'm pretty sure floating operations are safe by default on latest main

I saw the functions, and nope, they aren’t safe

ShaharMS commented 1 year ago

Did you merge latest main? I just looked at the code and floating operations check for safety

Wither362 commented 1 year ago

Oh! Now I see the changes, thanks!

Wither362 commented 1 year ago

Where’s pixel (0, 1)?

ShaharMS commented 1 year ago

woah, just merged main into your pr, and looks like java doesnt like some of the functions here... you can ignore that for now, its probably because of the inline abuse in that class😂

Wither362 commented 1 year ago

woah, just merged main into your pr, and looks like java doesnt like some of the functions here... you can ignore that for now, its probably because of the inline abuse in that class😂

:'( not happy wither… but thanks for merging it