Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my movie from UIImages gets distorted?

I'm using zoul's solution to export UIImage array as a movie. But my frames all turns out distorted. Here's the original image:

original image

Here's a similar distortion example:
similar distortion example

I've read here that it has something to do with aspect ratio, but there's no explanation on how to fix it.

like image 807
Geva Avatar asked Mar 13 '12 20:03

Geva


People also ask

What causes image distortion?

Image distortion is when the straight lines of an image appear to be deformed or curved unnaturally, creating different distortion types, including barrel, pincushion, and waveform. Distortion is often the result of the lens's geometrics and can significantly disrupt the image's quality.

Which filter helps to reduce distortion of images?

The Lens Correction filter helps to counteract some of these imperfections.

How do you get rid of barrel distortion?

As distortion is caused by the effects of perspective on the lens, the only way to correct for barrel lens distortion in-camera is to use a special "tilt and shift" lens, which is designed for architectural purposes. However, these lenses are costly, and only really make sense if you specialize in this field.


1 Answers

For those still doing the journey in 2020, and getting distortion in their movies because its not width 16px

change

CGContextRef context = CGBitmapContextCreate(pxdata,
                                             width, height,
                                             8, 4 * width,
                                             rgbColorSpace,
                                             kCGImageAlphaNoneSkipFirst);

to

CGContextRef context = CGBitmapContextCreate(pxdata,
                                             width, height,
                                             8, CVPixelBufferGetBytesPerRow(pxbuffer),
                                             rgbColorSpace,
                                             kCGImageAlphaNoneSkipFirst);

Credit to @Bluedays Output from AVAssetWriter (UIImages written to video) distorted

like image 82
Daryl Teo Avatar answered Nov 15 '22 21:11

Daryl Teo