Giter VIP home page Giter VIP logo

praveenvnktsh / hardware-accelerated-motion-estimation-using-fsbm-and-fpga Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 28.29 MB

FPGA Implementation of Full Search Block matching using an asynchronous handshake based FSM.

Coq 5.77% VHDL 92.51% Pascal 0.01% Verilog 1.35% Stata 0.02% Shell 0.19% Forth 0.01% Tcl 0.02% Batchfile 0.01% Python 0.01% C 0.03% HTML 0.07% PureBasic 0.01% JavaScript 0.02%
vga coe macroblock bram pixels verilog-hdl fpga basys3 basys3-fpga python

hardware-accelerated-motion-estimation-using-fsbm-and-fpga's Introduction

Hardware Accelerated Motion Estimation using Block Matching

This project implements block matching using full search between two consecutive 96 x 96 pixel frames of a video sequence and displays the motion vectors on a VGA display. This project was implemented as part of the ES203 course on Digtal Systems at IIT Gandhinagar during the academic year 2019-20.


Prerequisites

  • Python 3
  • Vivado by Xilinx Inc (v2018.3 or higher)
  • Nexys 4 DDR FPGA

General Information on the algorithm

  • Algorithm: Block Matching using Full Search
  • FPGA Board : Nexys 4 DDR
  • Image frame Size : 96 x 96 pixels
  • Macroblock Size : 16 x 16 pixels
  • Search Area Size : 48 x 48 pixels

Description of code

  1. main.py

[ Input: .png image file | Output: .coe file ]

This Python script iterates over all pixels of the input file and converts their RGB values into binary values by concatenating the R, G, and B values into a single 24 bits (8 bits for each colour) value. Then it stores these values for all pixels in an array in a .coe file, which is then used to generate Block RAM on FPGA using an IP core. We generate two separate .coe files for the two consecutive frames.

  1. main.v

[ Input: Clock, Reset | Output: VGA and seven segment display]

This block uses a state machine approach in performing the algorithm. In order to change the state of a particular block a handshake like approach is used where each block requests its parent block for a state change, and the parent responds by changing the state of the child block. Each block has 4 major states - RESET, CALCULATING, DONE, COMPLETE.

This file has 4 main blocks that perform various actions -

  • Loading the .coe files into Block RAMs (BRAM) using 3 BRAMs
    • Dual-port BRAM for reading .coe file of frame 1 for performing the algorithm and for displaying. (frame1)
    • Single-port BRAM for reading the .coe file of frame 2 for performing the algorithm.
    • Dual-port BRAM for writing values to the addresses of start points and endpoints and reading the .coe file of frame 2 for displaying via VGA.
  • Calculating SAD (Sum of absolute differences)
    • This part takes as input intial address of macroblock and a block of size 16 x 16 pixels in the search frame of given macroblock and iterates over each pixel to find the sum of absolute differences for the blocks.
  • Finding the best match in a search area
    • This unit finds block in search area for which the total SAD is least with the macroblock. The centre of the best-matching block (endpoint) and the centre of the macroblock (start point) are the outputs of this unit. The search area definitions may vary depending on the macroblock type (if it is in the corner or in the middle or along an edge of the frame), so it handles the search area according to the address value.
  • Writing into BRAM and VGA Output-
    • It receives the start point and endpoint for each macroblock and colours endpoints white and start points black by writing into the Block RAM. Apart from this, the block also displays the output on a 640 x 480 VGA using locations as x and y coordinates. It also refreshes the frame and darkens the unused parts of the display.
  1. vga.v

[ Useful Inputs for displaying: Clock, Reset | Output: Co-ordinates and pixel values for diplaying on screen]

The vga.v file serves as a VGA controller by maintaining the HSYNC and VSYNC signals for the VGA display. By using a 25MHz clock, it also generates the current drawing x and y coordinates of the VGA display.

  1. tb.v

This file serves as a testbench for the entire program to run a simulation. Since no initial values are required for the simulation to run, the testbench simply initilializes an instance of the motion estimation block apart from generating the clock.

A seven segment display was also used for debugging purposes. Code for this can be found at the bottom of the main.v file.


Video

View a short explanation and demonstration of this project here: Watch the video

Authors

  • Praveen Venkatesh
  • Nishikant Parmar
  • Chris Francis
  • Prankush Agarwal

Acknowledgments

  • fpga4student.com
  • timetoexplore.net

hardware-accelerated-motion-estimation-using-fsbm-and-fpga's People

Contributors

praveenvnktsh avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.