Correzione distorsioni GoPro

da verificare:
http://www.rcgroups.com/forums/showthread.php?t=1711535

available at:
http://www.gimp.org/about/introduction.html

Updated menu selection
Filter ->Distort->Lens Distort
I used parameter values of
Main -64.8
Edge +16.43
all others left default a zero

If centerline of FOV is not perpendicular to subject of interest, you might want to consider adjusting the perspective to make parallel lines look parallel.

Updated menu selection
Tools->Transform Tools->Perspective
Parameters depend on subject

Per i video, verificare il plugin:
http://www.dyne.org/software/frei0r/

http://ubuntuforums.org/showthread.php?t=1854618
I’m not sure if FFmpeg can provide the solution for this, but your best bet with FFmpeg is probably lenscorrection from frei0r. You will have to compile FFmpeg to support frei0r because the version from the repository has no filtering capability last I checked:

sudo apt-get install frei0r-plugins-dev

Then install FFmpeg: HOWTO: Install and use the latest FFmpeg and x264

Add to the FFmpeg configure line:

--enable-frei0r

Then use it:

ffmpeg -i input -vcodec libx264 -preset medium -crf 24 -vf frei0r=lenscorrection:0.5:0.5:0.5:0.5 -acodec copy output.mp4

https://gist.github.com/KonradIT/ee685aee15ba1c3c44b4

In your GOPRO folder you should have photos in .JPG, use ImageMagick MOGRIFY:

mogrify -distort barrel "0 0 -0.3" *.JPG

It overwites all the .JPG files and correct them!

fisheye-correction.py :
modificare i parametri da GoPro2 a GoPro3 !

import  sys
import  cv
import  numpy as np
 
if  __name__ ==  '__main__' :
 
    vidFile =  cv.CaptureFromFile( '/media/user/8765-4321//DCIM/XXXGOPRO/GOPRXXXX.MP4'  )
 
    nframes =  int (cv.GetCaptureProperty (vidFile, cv.CV_CAP_PROP_FRAME_COUNT))
    fps =  cv.GetCaptureProperty (vidFile, cv.CV_CAP_PROP_FPS)
    waitPerFrameInMillisec =  int ( 1 / fps *  1000 / 1  )
    width =  int (cv.GetCaptureProperty (vidFile, cv.CV_CAP_PROP_FRAME_WIDTH))
    height =  int (cv.GetCaptureProperty (vidFile, cv.CV_CAP_PROP_FRAME_HEIGHT))
 
    print  'Num Frames = ' , nframes
    print  'Frame rate =' , fps, 'frames per sec'
 
    # Camera data for GoPro Hero2
    camera_matrix =  cv.CreateMat ( 3 , 3 , cv.CV_32FC1)
    cv.SetReal2D (camera_matrix, 0 , 0 , 469.96 )
    cv.SetReal2D (camera_matrix, 0 , 1 , 0.0 )
    cv.SetReal2D (camera_matrix, 0 , 2 , 640 )
    cv.SetReal2D (camera_matrix, 1 , 0 , 0.0 )
    cv.SetReal2D (camera_matrix, 1 , 1 , 467.68 )
    cv.SetReal2D (camera_matrix, 1 , 2 , 360 )
    cv.SetReal2D (camera_matrix, 2 , 0 , 0.0 )
    cv.SetReal2D (camera_matrix, 2 , 1 , 0.0 )
    cv.SetReal2D (camera_matrix, 2 , 2 , 1.0 )
 
    dist_coeffs =  cv.CreateMat ( 1 , 5 , cv.CV_32FC1)
    cv.SetReal2D (dist_coeffs, 0 , 0 , - 0.18957 )
    cv.SetReal2D (dist_coeffs, 0 , 1 , 0.037319 )
    cv.SetReal2D (dist_coeffs, 0 , 2 , 0.0 )
    cv.SetReal2D (dist_coeffs, 0 , 3 , 0.0 )
    cv.SetReal2D (dist_coeffs, 0 , 4 , - 0.00337 )
 
    # Prepare for new movie
    writer =  cv.CreateVideoWriter (
        filename =  "output.avi" ,
        # = Cv.CV_FOURCC fourcc ('M', 'J', 'P', 'G'),
        fourcc = - 1 , #with # -1 is selected in Windows
        fps = fps,
        frame_size = (width, height),
        is_color = 1 )
 
    map1 =  cv.CreateImage ((width, height), cv.IPL_DEPTH_32F, 1 )
    map2 =  cv.CreateImage ((width, height), cv.IPL_DEPTH_32F, 1 )
    cv.InitUndistortMap (camera_matrix, dist_coeffs, map1, map2)
 
    for  f in  xrange (nframes):
        frameImg =  cv.QueryFrame (vidFile)
        if  frameImg is  None :
            print  "no frame", f, "flawed. Cancel"
            break
        undistimage =  cv.CloneImage (frameImg)
        cv.Remap (frameImg, undistimage, map1, map2)
 
        cv.ShowImage ( "Video" , undistimage)
        cv.WriteFrame (writer, undistimage)
        cv.WaitKey (waitPerFrameInMillisec)
 
        # Progress Bar
        percent =  f * 100 / nframes
        print  percent, "%"
 
        k =  cv.WaitKey ( 1 )
        if  k %  0x100  ==  27 :
            # User has press the ESC key, then exit
            break
 
    cv.DestroyWindow ( "Video"  )
    del  writer

The presets I use for correcting the fisheye are:
HERO2:

Horizontal center: 450
Vertical center: 619
Center correction: 288
Edges correction: 456
Brightness: 562

HERO3:

Horizontal center: 378
Vertical center: 619
Center correction: 230
Edges correction: 300
Brightness: 562

HERO3+Black SuperView:

Horizontal center: 430
Vertical center: 619
Center correction: 270
Edges correction: 456
Brightness: 562

Lascia un commento

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...