Friday, April 29, 2016

Guide to Installing OpenCV+python setup on Windows [Video .avi/.mp4 problems Solved]

Hello Everyone. This will be my post after a long time and this time I've come up with something which I had got my nerves on while installing. The reason for creating this post was mainly the unavailability of proper installation procedure(Shocking!). This library isn't like those '.exe' softwares where a single installation would directly run the image processing tool. If you're new to OpenCV, no problem, I've got you covered.

1)Install python 2.7  :
Download the python 2.7 package from the python official site. Download according to your system configurations. Download and install from here.
Note: Install the Windows X86-64 MSI Installer (2.7.0) package if you're on a Windows 64 bit version.



2)Download the latest (Version 3.0) OpenCV stable version:

This step downloads the library in zip format which contains all the dependencies to be installed for successfully running OpenCV. Here's the link to the download page.Link

Next, extract the package on desktop and the extracted folder will be 'opencv'.




extracting the opencv package

folder after extraction


3) Download numpy library for python:


Download the numpy library which is the library for using matrices for python. Since you'll be using arrays extensively for image processing applications, this library is a must and no applications or functions will run without this library,

Download the package from here and directly install it into the directory where python is installed.

Note: When installing, the installation directory is default where your python is installed. So no need to change it.
4) Download FFpmeg :

This might probably the most important step in installing OpenCV on windows. FFmpeg is the required library for running video applications on OpenCV + python setup.
See here on how to install ffmpeg on windows.Please go through the tutorial, as I'm not covering here. Remember, this file is very important for video processing applications.

5) Setting up files for getting ready:

Now that you have installed all the requires libraries and packages. Now it's time to move some files.

i)    goto: Desktop\opencv\build\python\2.7\x86
      and copy the pyd file,


ii) goto: C:\Python27\Lib\site-packages

and paste the previously copied pyd file.


  


iii) goto: Desktop\opencv\build\bin and copy all the .dll files
and paste them to each C:\python27 and the ffmpeg/bin folder you created in step 4).





copy the files to c:\ffmpeg\bin folder.

5) Run a Sample:
goto: \Desktop\opencv\sources\samples\python2 and run any of the files. Here I'm showing you the optical flow example.

(Right click on the python file >Edit with IDLE> *python script will pop-up* > press F5 to start)


optical flow example
If you're still getting problems then mention it in the comments I'll try to solve them.
Thanks for watching,
Cheers!

Thursday, April 7, 2016

Traffic Count using OpenCV Python 'Moments' method | Code | Video

I'm currently working on various simple image processing modules at my internship and got permission to showcase my simple traffic count using a slightly different method than conventional blob analysis or contours method, which is moments method. The moments method works on the geometries of the image like centroid, area etc.

The following is the algorithm that i've applied:
  1. Get the Video frame by frame, thereby applying processing techniques for every frame/image.
  2. Apply Background subtraction. Generally when static background is present as in the case of a static CCTV camera, to get a binary image for the moving vehicles. We simply subtracted a static background from the current image thus leaving us with just the moving vehicles.
  3. Next, apply moments function to each frame, therefore getting the centroid of the moving vehicles( binary image).
  4. Finally assign a certain range of pixel values in (x,y) form on the frame so that when the centroid of the moment area crosses this range the counter increments by one which is reflected in the counter text. 
CODE:

VIDEO:

Here's a small video on how it works.







Simple Ball Tracking Robot | Code | Part 3

Hello guys, this is last and final part to the Simple Ball tracking robot. This robot though simple, took me around 3 months to build. Obviously with exams, Projects , deadlines and internship made it longer. Finally i'm uploading the code on Github.
The GitHub account contains two codes in the folder. First is the OpenCv Python code for tracking and the second one contains the serial receiving code for the Arduino Uno.
Also, i have put a trackbar file so that you can set HSV values according to the color of the ball which you want to track.
 In the future i'll make an extension to this project with the final full fledged robot included in the robot.
Click here for the Code



Sunday, April 3, 2016

GitHub Account for all Projects

I'm sharing here the link to all the repositories(projects) that I've made till date (Major Ones).