Simple Video Annotation Tool
This is a script to label the Scene in a Video based on the crowed density level. You can label the scene into 3 level, Empty, Half, and Full. In order to run this script we need to install OpenCV library on our system. Please follow the installation guide for your system.
How to run script
We assume that you install OpenCV and are ready to run the script. In ordor to download click here. Unzip the file and navigate into SceneDensity directory.
In Ubuntu 16.04
Open the Terminal inside the SceneDensity directory, activate the virtual environment you by following command.
Use the following command to run the annotation tool. You will see an instruction about how to use this tool.
In Windows 10
Open command prompt and use the command below to run the tool.You will see an instruction about how to use this tool.
Install OpenCV on Ubuntu
Open Terminal and use the following commands
cd ~ && mkdir OpenCV && cd OpenCV && wget https://raw.githubusercontent.com/ImOmid/SceneDensity/master/installDep.sh
Now, you should be inside OpenCv directory. Use the following command to install dependencies.
Please wait, it will take time. Afterwards, close the Terminal and open a new Terminal.
Create your Python Virtual Environment using following commands.
For Python 2.7 use:
mkvirtualenv OpenCV -p python2
For Python 3.5 use:
mkvirtualenv OpenCV -p python3
Use the following command to change your Python environment into the virtual environment you just created.
Install numpy in OpenCV virtual environment using following command.
pip install numpy
Change the current working directory.
Use the following command to change the directory to build directory.
Configure the build
Use the following command to configure the build. Copy and paste it into the Terminal. Current working directory must be build.
cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D INSTALL_C_EXAMPLES=OFF \ -D OPENCV_EXTRA_MODULES_PATH=~/OpenCV/opencv_contrib-3.2.0/modules \ -D PYTHON_EXECUTABLE=~/.virtualenvs/OpenCV/bin/python \ -D BUILD_EXAMPLES=ON ../opencv-3.2.0
Be sure to check the output of CMake before going to next step. You sould see an output in which cmake found the Interpreter, Libraries, numpy path for Python. The output is similar to YouTube Video on How to build and Install OpenCV 3.2 Python on Ubuntu 16.04.
If there is no error in the previsous pass, use the following command to compile OpenCV.
It can take up to 2 hours based on your Computer specifications. Be patient!
If the compile finished without any error go to next step. Otherwise, use the following command to clean and make again.
make clean && make
Use the below commands to install OpenCV
sudo make install sudo ldconfig
Finish OpenCV installation
Use the folllowing commands to build a symbolic link for OpenCV cv2.so.
For Python 2.7:
cd ~/.virtualenvs/OpenCV/lib/python2.7/site-packages/ ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so
For Python 3.5:
cd /usr/local/lib/python3.5/site-packages/ sudo mv cv2.cpython-35m-x86_64-linux-gnu.so cv2.so # Rename the file cd ~/.virtualenvs/cv/lib/python3.5/site-packages/ ln -s /usr/local/lib/python3.5/site-packages/cv2.so cv2.so
Test OpenCV install
If all the previous steps are done successfully. You should be able to import OpenCV in your virtual environment. Use the following commands to verify it.
Open python inside OpenCV virtula environment.
cd ~ workon OpenCV python
In the python interpereter import cv2 and check its version.
import cv2 cv2.__version__
The output should be '3.2.0'
Install OpenCV on Ubuntu 10 Windows
Download and install dependencies
- Download and install Visual Studio and CMake.
- Download and install necessary Python, and Numpy to their default locations.
Download and extract OpenCV and OpenCV_contrib
Extract both zip files into:
and create a build directory in:
Configure and Generate
Run CMake as administrator
Browse the source code and build directories as follows.
Where is the source code:
Where to build the binaries
Click Configure and specify native compilers. For C & C++ compilers browse following.
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Vc\bin\cl.exe
Click Finish and wait until Configuring done.
Look for OPENCV_EXTRA_MODULES_PATH and set it as follows.
Then click Configure and wait until it is done.
Click Generate and wait for it to finish. When it is done close CMake.
- Got to:
directory and run "OpenCV.sln" with Visual Studio.
Change the Debug mode to Release mode (you'll find it the middle of toolbar). Wait for the projects to get ready. Check if it is written Ready in the bottom left corner of the Visual Studio window.
When the projects are ready, Right Click on All_BUILD and select Build (you'll find in the solution explorer on the right of Visual Studio). It will take a while, wait until it finishes.
Right Click on INSTALL (right under ALL_BUILD) and select Build. When it finishes close the Visual Studio.
Copy build files
Copy cv2.pyc file from:
If there is a file with the same name replace it.
Copy *.dll files
Copy all the dll files from:
Add Python and OpenCV into PATH
Right Click on My Computer and select properties.
Go to Advanced system settings (on top left corner) and select Environment Variables (on Advanced tab and at the bottom), and click on Path from the System variables section and click Edit.
Add all the following pathes by each time clicking on New
C:\Python27 C:\Python27\Lib\site-packages C:\Python\Scripts C:\OpenCV\build\lib\Release C:\OpenCV\build\install\x86\vc11\bin C:\OpenCV\build\install\x86\vc11\lib
- Click OK on all setting windows you have opened.
Open Command prompt and run the following commands.
- Run python
- Python interpreter must be run. To check if you installed OpenCV successfully import cv2 and check its version by following commands in Python interpreter.
import cv2 cv2.__version__
You should see '3.2.0'
You can watch the Video Tutorial on How to build and Install OpenCV 3.2 from source for Python on Windows 10