- Install Opencv Visual Studio Code
- Visual Studio Code Opencv Install
- Opencv Vs Code
- Visual Studio Code Opencv Ubuntu
- Visual Studio Code Opencv
In this article, you will learn an easy way to utilize face-recognition software by using OpenCV.
But it is almost same for other versions of OpenCV, Microsoft Visual Studio and Microsoft Windows. If you want, you can refer to my older posts. Installing & Configuring OpenCV 2.4.5 with Visual Studio 2012; Installing & Configuring OpenCV 2.1 with Visual Studio 2010; There are 2 ways to install OpenCV into your computer. Open the file explorer and navigate to the following path: '%OCV2015ROOT% vs2015 WS 10.0 x86', then open OpenCV.sln in Visual Studio. On the top of the screen, next to the green Run button, select Release instead of Debug and Win32 instead of ARM or x64.
OpenCV (Open Source Computer Vision) is released under a BSD license, and thus is free for both academic and commercial use. It has C++, C, Python, and Java interfaces and supports Windows, Linux, Mac OS, iOS, and Android operating systems. OpenCV was designed for computational efficiency, with a strong focus on real-time applications. Written in C/C++ coding languages, its vast library of code can take advantage of multi-core processing.
Adopted all around the world, OpenCV has more than 47 thousand people in its user communities, and has been downloaded more than 9 million times. Usage ranges from interactive art to the detection of mines and from online maps to advanced robotics.
Steps:¶
Step 1:Install Visual Studio 2017 and OpenCV¶
1.Install Visual Studio 2017 on your computer
Head over to https://www.visualstudio.com/products/visual-studio-professional-with-msdn-vs and download Visual Studio Professional 2015. Unzip the downloaded file and double-click the 'vs_professional.exe'. Then, the installation process will begin.
2.Install OpenCV
1) Head over to the site: http://www.opencv.org and download the latest version of OpenCV (shown in the figure below). Choose the correct version which corresponds with the operating system of your computer.
In this tutorial we are going to install OpenCV 3.1 using Visual Studio 2015 professional on a 64-bit system running Windows 10.
2) Extract the contents of the downloaded OpenCV fileDouble click the downloaded OpenCV file to start the extraction process of its various contents
Step 2: Set the Environment Variables¶
1.To do this step, open the Control Panel and then System. Next, click the Advanced System Settings. Finally, click Environment Variables. Please refer to the following image to locate these buttons and settings.
2.Edit the PATH environment variables and Add a new environment variable. Then, give it the value of F:opencvbuildx64vc14bin
. Note that this destination value must be in accordance with the name of the file path destination where you extracted your OpenCV in step 2.
Step 3: Create a New Project in Visual Studio 2017¶
1.In Visual Studio 2017, create a new project
2.Select Win32 Console Application in Visual C++. Then, name your project and select a directory to store this project
3.Choose empty project and click finish
4.Add a new cpp file (to learn how to add a new cpp file, refer to the images below)
Step 4: Configure OpenCV in Visual Studio 2017¶
1.Open the Property Manager and double click Debug|Win64
2.Select 'Include Directories', and type in the following values:
F:opencvbuildinclude
F:opencvbuildincludeopencv
F:opencvbuildincludeopencv2
Remember to change the value fo match the file path destination where you have extracted your OpenCV files to in step 2.
3.Add Library Directories, and type in the valueF:opencvbuildx64vc14lib
. Remember to change the value fo match the file path destination where you have extracted your OpenCV files to in step 2.
4.Add Additional Dependencies
Copy the following item and paste it into the Additional Dependencies field opencv_world310d.lib
Step 5: Paste the Following Code to the .cpp File You Added in Step 4.¶
Step 6: Debug Your Project¶
Set up the two options as follows in the figure below:
Press F5 to execute the face detection project. Now, your PC camera will turn on, and your face and eyes will be highlighted like so:
References:¶
1.http://www.michaelpsyllakis.com/install-opencv-on-visual-studio-2015-community-tutorial/ 2.http://docs.opencv.org/2.4/opencv_tutorials.pdf
3.http://docs.opencv.org/2.4/opencv2refman.pdf
This Vs Code extension provides the user with Opencv snippets in python. It helps in effectively providing, refactoring and editing the opencv projects in python3. All the snippets starts with 'o', so typing a letter o gives recommendation for all the available opencv snippets.
Example -
This Example detects corner in the image.
This Example detects shapes in the image.
From the examples above, it can be easily seen that how easy and fast it become to code in Opencv by using this extension. It also saves you from any syntactical mistakes and increase your coding speed by many folds.
Installation:
This Extension can be installed from the Visual Studio Code Marketplace or by searching within VS Code.
In VS code press ctrl+p and type ext install extensionName and press enter.
Snippets:
Trigger | Full Form | Description |
---|---|---|
orimg | Reading Image | Reads image from the computer |
owimg | Write Image | Write image in the computer |
odis | Display Image | Display Image |
orvid | Read Video | Read Video from camera or a Video File |
owvid | Write Video | Write Video in the computer |
oline | Draw Line | Draw Line on the image |
oaline | Draw Arrowed Line | Draw arrowed line on the image |
orect | Draw Rectangle | Draw Rectangle on the image |
ocircle | Draw Circle | Draw Circle on the image |
oellipse | Draw Ellipse | Draw Ellipse on the image |
opoly | Draw Closed Polygon | Draw any Polygon on the image |
otext | Write Text | Put any text on the image |
olistevents | Listing Events | List all the events available in opencv |
ohmevent | Handling Mouse Events | Provide basic Layout to handle all mouse events |
octrack | Create Trackbar | Creates trackbar on any window |
otrackpos | Get Trackbar Position | Gives the position of trackbar at any time |
ocvtcolor | Convert Color | Converts color from one format to other |
ohsvcoloriden | Identify Color using HSV | Identifies any color in the image |
othresh | Thresholding | Returns a threshold Image |
oathresh | Adaptive Thresholding | Returns Adaptive thresholded Image |
odilate | Dilate Image | Returns a Dilated image |
oerode | Erode Image | Returns a Eroded image |
omorphex | Morphological Transformations | Removes noises from the image by performing morphological transformations on it. |
oblur | Blur Image | Used for blurring or smoothening of image |
ogblur | Gaussian Blur | Returns Gaussian blur of a image |
omedblur | Median Blur | Used for smoothening of image using Median blur |
obblur | Bilateral Blur | Used for smoothening of image using Bilateral blur |
olapedge | Laplacian Edge Detector | Edge Identification using Laplacian Edge Detector |
osobedge | Sobel Edge Detector | Edge Identification using Sobel Edge Detector |
ocanny | Canny Edge Detector | Edge Identification using Canny Edge Detector |
ocontours | Contours | Identifies and draw contours on the image |
oshapedetect | Shape Detection | Detects shapes present in the image and writes the name of the shape in the image. |
omatchtem | Template Matching | Matches template in any main image and draws rectangle around the identified template in the main image |
ohough | Hough Line Transformation | Detects straight lines of infinite length in the image. |
ophough | Probabilistic Hough Line Transform | Detects straight lines of finite length in the image. |
ohaarc | Haar Cascades Classifier | Provide Layout for using Haar Cascades Classifier |
oharrisc | Harris Corner Detector | Detects corner in the Given image (Harris Corner Detector) |
ogoodf | Shi-Tomasi Corner Detector | Detects desired number of corners in the Given image (Shi-Tomasi Corner Detector) |
opers | Perspective Transformation | Returns the perspective transformation of the image |
oaffn | Affine Transformation | Returns the Affine Transformation of the image |
orotate | Rotate Image | Rotates the image by desired angle |
Requirements
- Python3 should be installed in the system.
For installing python latest version you can head over to python offcial website.
- Opencv library of python. This can be installed by executing the following command in the terminal or cmd.
- Numpy library of python. This can be installed by executing the following command in the terminal or cmd.
This need not be compulsorily installed but it is advised to install it because there are various snippets which require this library for better and smooth performance.
Issues
Report issues and bugs at Opencv Snippets Issues
Install Opencv Visual Studio Code
Release Notes
The detailed release notes of Opencv Snippets can be found at -
v1.2.2
- Bug fixes.
- Keywords added.
- Added more snippets.
v1.2.1
- Improvements and bug fixes.
- Code cleaned to make it more readable.
- Comments added.
v1.2.0
- More Snippets added.
- Better handling of triggers.
- Code quality improvements.
- Code should run faster now.
v1.1.2
- Reformating of code.
- Minor bug fixes.
v1.1.1
Visual Studio Code Opencv Install
- Added gifs and icons.
- readme prepared.
v1.1.0
Opencv Vs Code
- Added Multiple Snippets.
- Snippets made more generic.
- Code modularized.
v1.0.0
Visual Studio Code Opencv Ubuntu
- Initial Release of Opencv-Snippets
- Basic Layout of the project setup
- Added Image and Video read/write snippets.
License
Opencv Snippets is an open-sourced software licensed under the GNU GENERAL PUBLIC LICENSE.
About Me
- You can connect with me at linkedin:
- You can follow me on github:
For more information
This is a open Source project, so for more information and contribution you can checkout:
Visual Studio Code Opencv
Enjoy!