-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--cg --vg resize: image streched #149
Comments
Can you do a PR to perform the streching/cropping based on a command line switch? TIA. |
Assume that we call backscrub with the arguments: The raw image (captured by the camera has an aspect ratio 4:3 the output image an aspect ratio of 1:1. Actually, the whole content of the raw image is resized so that the complete image fit to the wanted output size. This mean that a circle will, after resizing, will be an oval. The height is. for this case bigger as the width. If we take into account only a centered area and crop first the raw image, a circle will remain a circle. |
I have modified deepseg.c as follow: added after the last variable declaration within main()
Before the mainloop added:
The code will only be passed if we are scaling down! Scaling occur with the following:
This seems to work well. |
I have added cropping of capture and background. In order to do so I modified 4 files. |
There are some code style issues with these patches (mostly indentation and tabs/spaces). Also I noticed some typos. Please put those patches into a PR. This makes working and reviewing those patches much easier. Given that you already got those patches from git, it's not to hard to create and upload a branch containing those changes. |
Sorry, but my English is not so good. |
Thanks for the effort so far @jjsarton, it's looking good 👍 . From my understanding of the code, this will always crop both input video and background video to the output aspect ratio, when the output is smaller than the input in both dimensions, otherwise it will scale as before (including any distortions that may produce). This is opinionated behaviour, which as @BenBE asked (#149 (comment)) would be better with a command line switch to enable, leaving the existing behaviour (always scaling) as the default. |
I may use a switch, this is not a big problem. As far I can think about background distortion, this appeared first with the use of different aspect ratio for input and output. Above cited comment apply only on the newest version with the --cg and --vg. Therefor, I can't imagine that there is a lot of people which want a distorted background. Actually I have a development version and I have some changes within deepscrub.cc. I have put the message (showUsage) within a function, corrected a little argument parsing, tried to fix bugs in front of the display. If a wrong argument is recognized, I print first the usage and then the error message. There are of course other modification which shall avoid crashes. A lot of tests are to be performed, with many inputs and outputs (camera, background, output size, …). This requires a lot of time. |
If we don't have the same aspect ratio for the camera and the video output the result is not very pretty.
For this case, we can calculate the region we will scale. For example, if --cg is 640x480 and --vg is 480x480, we my calculate the region to be processed and set
and call
instead of
This allows to get a non distorted output.
The text was updated successfully, but these errors were encountered: