tony-xlh / vision-camera-cropper

A vision camera frame processor plugin for cropping
MIT License
13 stars 3 forks source link

Rotatation, crop in pixels, not % #5

Open tarasovladislav opened 2 weeks ago

tarasovladislav commented 2 weeks ago

Hi, would be nice if its possible to set height and width in pixels, not %.

Also, is it possible to add rotation prop before frame is cropped?

xulihang commented 2 weeks ago

You can calculate the percentage based on the desired region and frame's size. I don't think it is really needed to support pixel as well.

As for the rotation prop, I don't know what it is used for.

tarasovladislav commented 2 weeks ago

@xulihang Hi, thanks for your answer, alright with px.

But regarding rotation: https://github.com/mrousavy/vision-camera-resize-plugin/issues/43#issuecomment-1981324379

device.sensorOrientation - but this is not guaranteed to be correct by Android. Some vendors choose to not implement it properly, specifically on Samsungs it's 180 deg rotated.

CameraX has workarounds for all such quirks, in VisionCamera V4 that should be fixed.

So I just copied your sample and on my samsung images are rotated 180 so instead of cropping from top, it crops from bottom.

xulihang commented 2 weeks ago

Okay. The plugin automatically rotates the frames so that it matches the preview. But it seems that Samsung phones not work in the same way.

I will add a rotation option but you have to enable it based on difference devices

xulihang commented 1 week ago

I added a method to rotate an image in v1.1.0.