Super-resolution of license plate in video sequence

asked 2014-02-26 14:02:10 -0500

salgarcia gravatar image

updated 2014-02-26 14:12:32 -0500

berak gravatar image

This is a follow up question to my question here:

I implemented a basic super-resolution technique suggested by the answer, but I am having trouble obtaining better resolution results. I trimmed the video sequence to 40 frames as seen below:enter image description here

and using the code below, which takes the first 5 frames and performs Super-resolution, then the super-resolved frame is repeatedly updated with the processing of the rest of the frames in the sequence:

public void Process(Image<Gray, byte> frame)

        var resizedFrame = ResizeFrame(frame);

        if(InputFrames.Count > 5)

    public void PerformSuperResolution()
        // WindowSize = 5
        var referenceFrame = InputFrames[WindowSize-1].Convert<Gray, byte>();
        var featuresToTrack = referenceFrame.GoodFeaturesToTrack(100, 0.1, 5, 10);

        referenceFrame.FindCornerSubPix(featuresToTrack, new Size(WindowSize,WindowSize), new Size(-1,-1), new MCvTermCriteria(20, 0.03d));

        var resultFrame = InputFrames[WindowSize-1].Convert<Gray, double>();
        for(var frameCounter = 0; frameCounter < WindowSize-1; frameCounter++)
            // Get shift between frames
            var shiftResult = GetShiftResult(InputFrames[frameCounter],referenceFrame, featuresToTrack);

            // Warp to correct shift
            var warpMatrix = new Matrix<double>(new[,] { {1, 0, -shiftResult.ShiftX}, {0, 1, -shiftResult.ShiftY}, {0, 0, 1}});

            var warpedFrame = InputFrames[frameCounter].WarpPerspective(warpMatrix, 
                new Gray(0)); 

            resultFrame.RunningAvg(warpedFrame.Convert<Gray,double>(), 1, resultFrame.Convert<Gray, byte>());
        SuperResolutionFrame = resultFrame.Convert<Gray, byte>();

    public ShiftResult GetShiftResult(Image<Gray, byte> inputFrame, Image<Gray, byte> referenceFrame, PointF[][] ActualFeature)
        var result = new ShiftResult();

        PointF[] NextFeature;
        Byte[] Status;
        float[] TrackError;

        // optical flow
        OpticalFlow.PyrLK(referenceFrame, inputFrame, ActualFeature[0], 
            new Size(WindowSize, WindowSize), 5, new MCvTermCriteria(20, 0.1d), 
            out NextFeature, out Status, out TrackError);

        //get displacements
        float[] XdisplacementVectors = new float[NextFeature.Length];
        float[] YdisplacementVectors = new float[NextFeature.Length];
        for(int i = 0; i < NextFeature.Length; i++)
            XdisplacementVectors[i] = NextFeature[i].X - ActualFeature[0][i].X;
            YdisplacementVectors[i] = NextFeature[i].Y - ActualFeature[0][i].Y;

        // gets average of displacements (disregards outliers)
        result.ShiftX = getAVG(XdisplacementVectors);
        result.ShiftY = getAVG(YdisplacementVectors);

        return result;

where the program calls Process(frame) on an array of input video frames (totaling 40) as such:

for(int i  = 0; i < image_array.Count; i++)

and I obtained this resulting image: enter image description here

As you can see there are only small improvements in the overall resolution, and not much improvement to the readability of the license plate. I've tried experimenting with the various parameters, but the parameters used above seem to be the best I can do.

I am open to any suggestions for improvement (need not be limited to the use of C#/Emgu CV as above), and even different approaches in implementation.

edit retag flag offensive close merge delete


you've seen the wiener filter ? currently, there's only a python demo for it, but it seems to be a quite nice tool to handle motion blur (though i got no idea if it works with video, ie continuous data with changing camera direction)

berak gravatar imageberak ( 2014-02-26 14:19:13 -0500 )edit