Closed AyishwaryaM closed 1 year ago
You would need to calibrate the distortion coefficients as described in the publication. If you take a clear good contrast image of an accurate grid of clearly imaged dots or grid of squares (easy for the image analysis to segment) then the software should be able to find the distortion coefficients . You can then apply them to the images with the other software or your own. What we wrote would only apply to frames, not to the video (compressed) directly, if you have a program that process video in memory you could add the unwarp method into it.
https://discorpy.readthedocs.io/en/latest/usage/demo_04.html
From: AyishwaryaM @.> Sent: 30 March 2023 07:05 To: DiamondLightSource/discorpy @.> Cc: Subscribed @.***> Subject: [DiamondLightSource/discorpy] Issue in removing fisheye effect from face (Issue #4)
Hi Developers, I want to remove fisheye distortion from a face, I tried with every possible way but not get a proper output. I am trying since last 1 month but not getting success.
I came to know about this discorpy library, can this library help to remove fisheye distortion from a face. I will share one sample frame of my video from which I want to remove fisheye distortion.
— Reply to this email directly, view it on GitHubhttps://github.com/DiamondLightSource/discorpy/issues/4, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC4TESRUFLNCFP3COPXWLK3W6UPAXANCNFSM6AAAAAAWMZUFWU. You are receiving this because you are subscribed to this thread.Message ID: @.**@.>>
-- This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail. Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message. Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom
You can follow the instructions here to correct distortion for your camera: https://discorpy.readthedocs.io/en/latest/usage/demo_06.html that tutorial was written for commercial camera. If you can't get a calibration image, still can correct following this demo: https://discorpy.readthedocs.io/en/latest/usage/demo_08.html Note that we need some straight-line features in your image.
For video correction, you can use Opencv and coefficients calculated from Discorpy to unwarp each frame. You can copy a function here (unwarp_image_backward_cv): https://github.com/nghia-vo/vounwarp/commit/1f509aa81f86c6b27d611c8b924c1e7b45410169#diff-756cce26c21174cc77026213818dd5d33ebe5ea498ce800698f392c01cf0bca8 . The mapping function in Opencv is much faster than Scipy which is suitable for video processing.
Thanks for reply ! Can you please tell us what are the coefficients in coefficients.txt ? Whether they are distortion coefficients ?
https://discorpy.readthedocs.io/en/latest/usage/demo_01.html
Did you mean the output of this: ?
https://discorpy.readthedocs.io/en/latest/usage/demo_04.html io.save_metadata_txt(output_base + "/coefficients.txt", xcenter, ycenter, list_fact)
From: AyishwaryaM @.> Sent: 31 March 2023 07:29 To: DiamondLightSource/discorpy @.> Cc: Atwood, Robert (DLSLtd,RAL,SCI) @.>; Comment @.> Subject: Re: [DiamondLightSource/discorpy] Issue in removing fisheye effect from face (Issue #4)
Thanks for reply ! Can you please tell us what are the coefficients in coefficients.txt ? Whether they are distortion coefficients ?
— Reply to this email directly, view it on GitHubhttps://github.com/DiamondLightSource/discorpy/issues/4#issuecomment-1491381877, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC4TESTGWMEWYN5YRGA7OZDW6Z2TVANCNFSM6AAAAAAWMZUFWU. You are receiving this because you commented.Message ID: @.**@.>>
-- This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail. Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message. Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom
Yes, they are distortion coefficients as example here: https://github.com/DiamondLightSource/discorpy/blob/master/data/coef_dot_05.txt To summarize:
I hope the instructions are clear enough to follow. Otherwise you can reopen the issue and post your codes + checkboard image here so I can have a look.
I've added tips on how to perform distortion correction for video here: https://discorpy.readthedocs.io/en/latest/usage/tips.html
@nghia-vo, @algotom can we measure how much is our given image (face image) is perspective-distorted? You mentioned that straight-line features are needed, but in case of face image I'm not sure how can we obtain straight-line feature. Following the demo_05.py I got following results for normal face image (not distorted) but the plot of parabola coefficients didn't match the pattern for non distorted image, I'm new to image distortion topic so I may be doing smth wrong, please help me to measure how much face image is perspective-distorted.
Horizontal slope: 0.07566408117337668. Vertical slope: -0.6045881752695317
We need reference objects (straight lines, square-grid objects, ....) to be able to tell if there's distortion and how much. Straight lines are needed for radial distortion which curves straight lines. If you want to evaluate perspective distortion only, we need an image of a line-grid pattern: https://discorpy.readthedocs.io/en/latest/tutorials/methods/line_pattern.html.
If you are new to the topics, check these tutorials: https://discorpy.readthedocs.io/en/latest/tutorials.html to get an overview.
Back to your problem, we can't evaluate perspective distortion because: 1) there's no reference, 2) we don't know the cause of the perspective distortion (check this: https://discorpy.readthedocs.io/en/latest/tutorials/causes.html); it can be from the camera or from the object.
Documents and demos in Discorpy are concise and detailed enough to give you an overview about the methods and potential applications. Read them through will help you to narrow down your problem and tackle it properly.
Hi Developers, I want to remove fisheye distortion from a face, I tried with every possible way but not get a proper output. I am trying since last 1 month but not getting success.
I came to know about this discorpy library, can this library help to remove fisheye distortion from a face. I will share one sample frame of my video from which I want to remove fisheye distortion.
Please reply soon. Thanks in advance !