tag:blogger.com,1999:blog-20185866806426792092024-03-06T09:53:15.373+05:30Opencv C++ TutorialOpenCV Tutorials - C++ source code for beginner using OpenCV library and Visual Studio on image processing, object detection and tracking. All Basics of Open CV API.Rachit Gulatihttp://www.blogger.com/profile/13006436391845917580noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-2018586680642679209.post-76819710522878040072016-11-14T17:15:00.000+05:302018-03-30T15:07:32.406+05:30OpenCV Tutorials<div dir="ltr" style="text-align: left;" trbidi="on">
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd6jtnRa-IGdefYY9qF416fboOb_1t80sC274HJxRlMgLS5xL63uRJIXnnSlgGITj0Bwx7wG6yDj2yb6rfkk1XX-0QgAvnOyQ8bYfLdLu5tgVwHOkGjPq4O4HRDiOjKaPPLJEL1La6NQI/s1600/opencv-cpp.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="OpenCV Library, OpenCV API" border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd6jtnRa-IGdefYY9qF416fboOb_1t80sC274HJxRlMgLS5xL63uRJIXnnSlgGITj0Bwx7wG6yDj2yb6rfkk1XX-0QgAvnOyQ8bYfLdLu5tgVwHOkGjPq4O4HRDiOjKaPPLJEL1La6NQI/s320/opencv-cpp.png" title="OpenCV Tutorials" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>OpenCV Cpp Tutorials</b></td></tr>
</tbody></table>
<div style="text-align: justify;">
<b>OpenCV</b>, open source C++ library for image processing, originally developed by Intel. OpenCV is free for both commercial and non-commercial use. OpenCV library inbuilt functions mainly aimed at real time image processing.
It consist of several hundreds of image processing and computer vision algorithms which make developing of applications easy and efficient. Computer vision which go beyond image processing, helps to obtain relevant information from images and make decisions based on that information.</div>
<br />
<h2>
OpenCV Features</h2>
<ul>
<li>Optimized for real time image processing & computer vision applications.</li>
<li>Primary interface of OpenCV is in C++ but also available in C, Python and JAVA.</li>
<li>OpenCV applications run on Windows, Android, Linux, Mac and iOS.</li>
<li>Optimized for Intel processors.</li>
</ul>
<a href="http://opencv.org/downloads.html" rel="nofollow" target="_blank">Download OpenCV</a>
<br />
<br />
<h2>
Visual Studio IDE</h2>
<div style="text-align: justify;">
<b>Microsoft Visual Studio 2015</b> is an integrated development environment (IDE) from Microsoft.
It is used to develop computer programs for Microsoft Windows, as well as web sites, web applications and web services.
Microsoft provides Community editions, which support plugins, at no cost to all users.</div>
<a href="https://www.visualstudio.com/downloads/" rel="nofollow" target="_blank">Download Visual Studio Community</a>
<br />
<br />
<h2>
OpenCV Tutorials List</h2>
OpenCV Tutorials, <i>using OpenCV 3.1.0 and Visual Studio 2015 Community Edition on Windows 10</i>:<br />
<ul>
<h3>
<li><a href="http://opencv-cpp.blogspot.com/2016/10/installing-configuring-opencv-with-visual-studio.html" target="_blank">Installing & Configuring with Visual Studio</a></li>
</h3>
<h3>
<li><a href="http://opencv-cpp.blogspot.com/2016/11/blur-filter-effect-on-image.html" target="_blank">Apply Blur Filter Effect on an Image</a></li>
</h3>
<h3>
<li><a href="http://opencv-cpp.blogspot.com/2016/11/canny-edge-effect-on-image.html" target="_blank">Apply Canny Edge Effect on an Image</a></li>
</h3>
<h3>
<li><a href="http://opencv-cpp.blogspot.com/2016/11/erode-filter-effect-on-image.html" target="_blank">Apply Erode Filter Effect on an Image</a></li>
</h3>
<h3>
<li><a href="http://opencv-cpp.blogspot.com/2016/11/dilate-filter-effect-on-image.html" target="_blank">Apply Dilate Filter Effect on an Image</a></li>
</h3>
<h3>
<li><a href="http://opencv-cpp.blogspot.com/2016/11/negative-filter-effect-on-image.html" target="_blank">Apply Negative Filter Effect on an Image</a></li>
</h3>
<h3>
<li><a href="http://opencv-cpp.blogspot.com/2016/11/change-brightness-of-image.html" target="_blank">Change Brightness of an Image</a></li>
</h3>
<h3>
<li><a href="http://opencv-cpp.blogspot.com/2016/11/change-contrast-of-image.html" target="_blank">Change Contrast of an Image</a></li>
</h3>
<h3>
<li><a href="http://opencv-cpp.blogspot.com/2016/11/canny-edge-detection-on-webcam.html" target="_blank">Canny Edge Detection on Webcam</a></li>
</h3>
<h3>
<li><a href="http://opencv-cpp.blogspot.com/2016/10/object-detection-and-tracking-color-separation.html" target="_blank">Object Detection and Tracking using Color Separation</a></li>
</h3>
<li><i>More Tutorials Coming Soon...</i></li>
</ul>
<!-- adsense -->
<br />
<hr />
<b>Like, Share and Comment Below</b>
<br />
<hr />
</div>
Rachit Gulatihttp://www.blogger.com/profile/13006436391845917580noreply@blogger.com2India20.593684 78.962880000000041-8.5806465 37.654286000000042 49.7680145 120.27147400000004tag:blogger.com,1999:blog-2018586680642679209.post-26552615487114969362016-11-14T16:45:00.000+05:302018-03-30T15:11:53.350+05:30Canny Edge Detection on Webcam<div dir="ltr" style="text-align: left;" trbidi="on">
Steps to <b>Canny Edge Detection on Webcam | OpenCV with Visual Studio in Windows 10</b>. In this Tutorial, we are going to implement <i>Canny Edge Detection on Webcam</i> using OpenCV.<br />
<ol>
<li>First of all, Follow this tutorial to <a href="http://opencv-cpp.blogspot.com/2016/10/installing-configuring-opencv-with-visual-studio.html" rel="" target="_blank">Install & Configure OpenCV with Visual Studio 2015</a></li>
<div class="tab-content">
<pre>#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hp>
#include<iostream>
#include<conio.h>
int main() {
cv::VideoCapture capWebcam(0); // declare a VideoCapture object to associate webcam, 0 means use 1st (default) webcam
if (capWebcam.isOpened() == false) // To check if object was associated to webcam successfully
{
std::cout << "error: Webcam connect unsuccessful\n"; // if not then print error message
return(0); // and exit program
}
cv::Mat imgOriginal; // input image
cv::Mat imgGrayscale; // grayscale image
cv::Mat imgBlurred; // blured image
cv::Mat imgCanny; // Canny edge image
char charCheckForEscKey = 0;
int lowTh = 45;
int highTh = 90;
while (charCheckForEscKey != 27 && capWebcam.isOpened()) { // until the Esc key is pressed or webcam connection is lost
bool blnFrameReadSuccessfully = capWebcam.read(imgOriginal); // get next frame
if (!blnFrameReadSuccessfully || imgOriginal.empty()) { // if frame read unsuccessfully
std::cout << "error: frame can't read \n"; // print error message
break;
}
cv::cvtColor(imgOriginal, imgGrayscale, CV_BGR2GRAY); // convert to grayscale
cv::GaussianBlur(imgGrayscale,imgBlurred,cv::Size(5, 5),1.8); // Blur Effect
cv::Canny(imgBlurred,imgCanny,lowTh,highTh); // Canny Edge Image
//declare windows
cv::namedWindow("imgOriginal", CV_WINDOW_NORMAL);
cv::namedWindow("imgCanny", CV_WINDOW_NORMAL);
//declare trackbar
cv::createTrackbar("LowTh", "imgCanny", &lowTh, 100);
cv::createTrackbar("HighTh", "imgCanny", &highTh, 100);
// show windows
cv::imshow("imgOriginal", imgOriginal);
cv::imshow("imgCanny", imgCanny);
charCheckForEscKey = cv::waitKey(1); // delay and get key press
}
return(0);
}
</pre>
<b>OR</b><br />
Get <b>CannyCam.cpp</b> from Github:
<br />
<a class="btn btn-info" href="https://github.com/iamrachitgulati/image-filter" rel="nofollow" role="button" target="_blank">Download CannyCam.cpp</a>
</div>
<br />
<li>Paste full source code and Run it (Ctrl+F5 or F5).</li>
<br />
</ol>
<b>OUTPUT</b><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-7JzPEdMuRHnmHGYj-u_M4pcwSIEEOESblUijyUKdKLkIrF8iSUvmcGwg7N-wLg4XWfxZkXLd5afCS9px5cUEHh2P8sTV8D3OISSOEO6qBd70EWi5xFbviy81UL_CQ4IB3Vay4tII2Y/s1600/load-image-opencv.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Input Image OpenCV" border="0" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-7JzPEdMuRHnmHGYj-u_M4pcwSIEEOESblUijyUKdKLkIrF8iSUvmcGwg7N-wLg4XWfxZkXLd5afCS9px5cUEHh2P8sTV8D3OISSOEO6qBd70EWi5xFbviy81UL_CQ4IB3Vay4tII2Y/s400/load-image-opencv.PNG" title="Input Image OpenCV" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Original Webcam Image OpenCV</b></td></tr>
</tbody></table>
<div dir="ltr" style="text-align: left;" trbidi="on">
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqDwdKt0J4Z_6ZJV88CnyB0KlJ_QMhMKgWpALd6Q-uRt3iiGQFnvi0wxA_UOXe-R9XJSr0ZXbfw62xCgxGnqImIPndS3qkQIgfUcfv8oojDF7BZpReehvUstrB44yq3gAs-oxJ6XduH7A/s1600/Canny-Edge-openCV.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Canny Edge Detection Webcam OpenCV" border="0" height="216" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqDwdKt0J4Z_6ZJV88CnyB0KlJ_QMhMKgWpALd6Q-uRt3iiGQFnvi0wxA_UOXe-R9XJSr0ZXbfw62xCgxGnqImIPndS3qkQIgfUcfv8oojDF7BZpReehvUstrB44yq3gAs-oxJ6XduH7A/s400/Canny-Edge-openCV.PNG" title="Canny Edge Detection Webcam OpenCV" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Canny Edge Image Webcam OpenCV</b></td></tr>
</tbody></table>
<br />
<!-- adsense -->
<br />
<b>Explaination :</b> Function used: cv::Canny(imgBlurred,imgCanny,lowTh,highTh) - This function can process images and implement the Canny Edge Detector Algorithm.<br />
<ul>
<li>1<sup>st</sup> parameter is the source image.</li>
<li>2<sup>nd</sup> parameter is the destination or resultant image.</li>
<li>3<sup>rd</sup> parameter is the low threshold value.</li>
<li>4<sup>th</sup> parameter is the high threshold value.</li>
</ul>
<hr />
<b>Like, Share and Comment Below.</b>
<b>You may also like this</b><br />
<br />
<br />
<li><a href="http://opencv-cpp.blogspot.com/2016/11/canny-edge-effect-on-image.html">Apply Canny Edge Effect on an Image</a></li>
<br />
<hr />
</div>
</div>
Rachit Gulatihttp://www.blogger.com/profile/13006436391845917580noreply@blogger.com2India20.593684 78.962880000000041-8.5806465 37.654286000000042 49.7680145 120.27147400000004tag:blogger.com,1999:blog-2018586680642679209.post-52750918735532345212016-11-14T16:35:00.000+05:302018-03-30T15:11:29.923+05:30Apply Canny Edge Effect on an Image<div dir="ltr" style="text-align: left;" trbidi="on">
Steps to <b>Apply Canny Edge Effect on an Image | OpenCV with Visual Studio in Windows 10</b>. In this Tutorial, we are going to apply <i>Canny Edge Effect</i> on an image using OpenCV.<br />
<ol>
<li>First of all, Follow this tutorial to <a href="http://opencv-cpp.blogspot.com/2016/10/installing-configuring-opencv-with-visual-studio.html" rel="" target="_blank">Install & Configure OpenCV with Visual Studio 2015</a></li>
<br />
<li>Copy the Full Source Code to Apply Canny Edge on an Image from here:</li>
<div class="tab-content">
<pre>#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<iostream>
#include<conio.h>
int main() {
cv::Mat imgOriginal; // input image
cv::Mat imgGrayscale; // grayscale image
cv::Mat imgBlurred; // blured image
cv::Mat imgCanny; // Canny edge image
imgOriginal = cv::imread("C:/Briefcase/Chess.jpg"); // open image
if (imgOriginal.empty()) { // if unable to open image
std::cout << "error: image not read from file\n"; // show error message
return(0);
}
cv::cvtColor(imgOriginal, imgGrayscale, CV_BGR2GRAY); // convert to grayscale
cv::GaussianBlur(imgGrayscale,imgBlurred,cv::Size(5, 5),1.5); // Blur Effect
cv::Canny(imgBlurred,imgCanny,100,200); //Canny Effect
// declare windows
cv::namedWindow("imgOriginal", CV_WINDOW_AUTOSIZE);
cv::namedWindow("imgCanny", CV_WINDOW_AUTOSIZE);
// show windows
cv::imshow("imgOriginal", imgOriginal);
cv::imshow("imgCanny", imgCanny);
cv::waitKey(0);
return(0);
}
</pre>
<b>OR</b><br />Get <strong>CannyImg.cpp</strong> from Github:
<br />
<a class="btn btn-info" href="https://github.com/iamrachitgulati/image-filter" rel="nofollow" role="button" target="_blank">Download CannyImg.cpp</a>
</div>
<br />
<li>Paste full source code and Run it (Ctrl+F5 or F5).</li>
<br />
</ol>
<b>OUTPUT</b><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-7JzPEdMuRHnmHGYj-u_M4pcwSIEEOESblUijyUKdKLkIrF8iSUvmcGwg7N-wLg4XWfxZkXLd5afCS9px5cUEHh2P8sTV8D3OISSOEO6qBd70EWi5xFbviy81UL_CQ4IB3Vay4tII2Y/s1600/load-image-opencv.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Load an Image OpenCV" border="0" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-7JzPEdMuRHnmHGYj-u_M4pcwSIEEOESblUijyUKdKLkIrF8iSUvmcGwg7N-wLg4XWfxZkXLd5afCS9px5cUEHh2P8sTV8D3OISSOEO6qBd70EWi5xFbviy81UL_CQ4IB3Vay4tII2Y/s400/load-image-opencv.PNG" title="Load an Image OpenCV" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Load Image OpenCV</b></td></tr>
</tbody></table>
<div dir="ltr" style="text-align: left;" trbidi="on">
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqDwdKt0J4Z_6ZJV88CnyB0KlJ_QMhMKgWpALd6Q-uRt3iiGQFnvi0wxA_UOXe-R9XJSr0ZXbfw62xCgxGnqImIPndS3qkQIgfUcfv8oojDF7BZpReehvUstrB44yq3gAs-oxJ6XduH7A/s1600/Canny-Edge-openCV.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Canny Edge Effect OpenCV" border="0" height="216" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqDwdKt0J4Z_6ZJV88CnyB0KlJ_QMhMKgWpALd6Q-uRt3iiGQFnvi0wxA_UOXe-R9XJSr0ZXbfw62xCgxGnqImIPndS3qkQIgfUcfv8oojDF7BZpReehvUstrB44yq3gAs-oxJ6XduH7A/s400/Canny-Edge-openCV.PNG" title="Canny Edge Effect OpenCV" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Canny Edge Image OpenCV</b></td></tr>
</tbody></table>
<br />
<!-- adsense -->
<br />
<b>Explaination :</b> Function used: cv::Canny(imgBlurred,imgCanny,100,200) - This function can process images and implement the Canny Edge Detector Algorithm.<br />
<ul>
<li>1<sup>st</sup> parameter is the source image.</li>
<li>2<sup>nd</sup> parameter is the destination or resultant image.</li>
<li>3<sup>rd</sup> parameter is the low threshold value.</li>
<li>4<sup>th</sup> parameter is the high threshold value.</li>
</ul>
<hr />
<b>Like, Share and Comment Below.</b>
<b>You may also like this:</b><br />
<br />
<br />
<br />
<li><a href="http://opencv-cpp.blogspot.com/2016/11/canny-edge-detection-on-webcam.html">Canny Edge Detection on Webcam</a></li>
</div>
<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<hr />
</div>
</div>
Rachit Gulatihttp://www.blogger.com/profile/13006436391845917580noreply@blogger.com1India20.593684 78.962880000000041-8.5806465 37.654286000000042 49.7680145 120.27147400000004tag:blogger.com,1999:blog-2018586680642679209.post-13738817715791874192016-11-02T15:00:00.000+05:302018-03-30T15:11:18.664+05:30Change Contrast of an Image<div dir="ltr" style="text-align: left;" trbidi="on">
Steps to <b>Change Contrast of an Image | OpenCV with Visual Studio in Windows 10</b>. In this Tutorial, we are going to <i>increase and decrease contrast</i> of an image using OpenCV.<br />
<ol>
<li>First of all, Follow this tutorial to <a href="http://opencv-cpp.blogspot.com/2016/10/installing-configuring-opencv-with-visual-studio.html" target="_blank">Install & Configure OpenCV with Visual Studio 2015</a></li>
<br />
<li>Copy the Full Source Code to Change Contrast of an Image from here: </li>
<div class="tab-content">
<pre>
#include<opencv2/highgui/highgui.hpp>
using namespace cv;
int main()
{
//Load an Image
Mat img = imread("C:/Briefcase/Chess.jpg", CV_LOAD_IMAGE_COLOR);
namedWindow("Image", CV_WINDOW_AUTOSIZE);
imshow("Image", img);
//Change Contrast Effect
Mat imgInc;
img.convertTo(imgInc, -1, 2, 0); //increase (double) contrast
Mat imgDec;
img.convertTo(imgDec, -1, 0.5, 0); //decrease (halve) contrast
namedWindow("Inc contrast", CV_WINDOW_AUTOSIZE);
namedWindow("Dec contrast", CV_WINDOW_AUTOSIZE);
imshow("Inc contrast", imgInc);
imshow("Dec contrast", imgDec);
//Wait Key press
cvWaitKey(0);
//destroy windows
destroyAllWindows();
return 0;
}
</pre>
<b>OR</b><br />Get <strong>ChangeContrast.cpp</strong> from Github:
<br />
<a class="btn btn-info" href="https://github.com/iamrachitgulati/image-filter" rel="nofollow" role="button" target="_blank">Download ChangeContrast.cpp</a>
</div>
<br />
<li>Paste full source code and Run it (Ctrl+F5 or F5).</li>
<br />
</ol>
<b>OUTPUT</b><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-7JzPEdMuRHnmHGYj-u_M4pcwSIEEOESblUijyUKdKLkIrF8iSUvmcGwg7N-wLg4XWfxZkXLd5afCS9px5cUEHh2P8sTV8D3OISSOEO6qBd70EWi5xFbviy81UL_CQ4IB3Vay4tII2Y/s1600/load-image-opencv.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Load an Image OpenCV" border="0" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-7JzPEdMuRHnmHGYj-u_M4pcwSIEEOESblUijyUKdKLkIrF8iSUvmcGwg7N-wLg4XWfxZkXLd5afCS9px5cUEHh2P8sTV8D3OISSOEO6qBd70EWi5xFbviy81UL_CQ4IB3Vay4tII2Y/s400/load-image-opencv.PNG" title="Load an Image OpenCV" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Load Image OpenCV</b></td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg73mwxBR6EftjPhGwBywNUkCRCEpydprcd4a68DZL1ido_BLwwS__b013oi9UQ-ZNYPBub_i-UOSe2nkyMvya1vd2SdhPcyFgp1mmXNhcnSA6UjQI-GKlYvtE4n_aaMoTGTqi44S3sTYI/s1600/increase-contrast-opencv.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Increase Contrast of an Image" border="0" height="218" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg73mwxBR6EftjPhGwBywNUkCRCEpydprcd4a68DZL1ido_BLwwS__b013oi9UQ-ZNYPBub_i-UOSe2nkyMvya1vd2SdhPcyFgp1mmXNhcnSA6UjQI-GKlYvtE4n_aaMoTGTqi44S3sTYI/s400/increase-contrast-opencv.PNG" title="Increase Contrast of an Image" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Increase Contrast of an Image - OpenCV</b></td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdBuhRT8eLH2MSaqzlikTCfEPSQDlCXOW0hO6hh6I6olL8hjOQ6eoE5vrYR0asok_9ZiTmjZzeHkr2mcWpgCItkj96a-JoBhFGs7WBOpLC5fE1KJwHSTmsCv6fi8IovycM-vfARonG7qE/s1600/decrease-contrast-opencv.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Decrease Contrast of an Image" border="0" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdBuhRT8eLH2MSaqzlikTCfEPSQDlCXOW0hO6hh6I6olL8hjOQ6eoE5vrYR0asok_9ZiTmjZzeHkr2mcWpgCItkj96a-JoBhFGs7WBOpLC5fE1KJwHSTmsCv6fi8IovycM-vfARonG7qE/s400/decrease-contrast-opencv.PNG" title="Decrease Contrast of an Image" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Decrease Contrast of an Image - OpenCV</b></td></tr>
</tbody></table>
<br />
<!-- adsense -->
<br />
<b>Explaination :</b><br />
Function used:<br />
img.convertTo(imgInc, -1, 2, 0) - This function can process images and increase(double) contrast.
<br />
img.convertTo(imgDec, -1, 0.5, 0) - This function can process images and decrease(halve) contrast.<br />
<ul>
<li>1<sup>st</sup> parameter is the output matrix.</li>
<li>2<sup>nd</sup> parameter is Depth of the output image. If rtype is negative, output type is same as the input type.</li>
<li>3<sup>rd</sup> parameter is the multiplication or scaling factor, every pixel will be multiplied by this value.</li>
<li>4<sup>th</sup> parameter is delta factor added to the scaled values.</li>
</ul>
<br />
<hr />
<b>Like, Share and Comment Below.</b>
<b>You may also like this:</b><br />
<br />
<br />
<br />
<li><a href="http://opencv-cpp.blogspot.com/2016/11/change-brightness-of-image.html">Change Brightness of an Image</a></li>
<br />
<hr />
</div>
Rachit Gulatihttp://www.blogger.com/profile/13006436391845917580noreply@blogger.com1India20.593684 78.962880000000041-8.5806465 37.654286000000042 49.7680145 120.27147400000004tag:blogger.com,1999:blog-2018586680642679209.post-756167342300745312016-11-02T14:48:00.000+05:302018-03-30T15:11:09.381+05:30Change Brightness of an Image<div dir="ltr" style="text-align: left;" trbidi="on">
Steps to <b>Change Brightness of an Image | OpenCV with Visual Studio in Windows 10</b>. In this Tutorial, we are going to <i>increase and decrease brightness</i> of an image using OpenCV.<br />
<ol>
<li>First of all, Follow this tutorial to <a href="http://opencv-cpp.blogspot.com/2016/10/installing-configuring-opencv-with-visual-studio.html" target="_blank">Install & Configure OpenCV with Visual Studio 2015</a></li>
<br />
<li>Copy the Full Source Code to Change Brightness of an Image from here: </li>
<div class="tab-content">
<pre>
#include<opencv2/highgui/highgui.hpp>
using namespace cv;
int main()
{
//Load an Image
Mat img = imread("C:/Briefcase/Chess.jpg", CV_LOAD_IMAGE_COLOR);
namedWindow("Image", CV_WINDOW_AUTOSIZE);
imshow("Image", img);
//Change Brightness Effect
Mat imgInc;
img.convertTo(imgInc, -1, 1, 25); //increase brightness by 25 units
Mat imgDec;
img.convertTo(imgDec, -1, 1, -25); //decrease brightness by 25 units
namedWindow("Inc Brightness", CV_WINDOW_AUTOSIZE);
namedWindow("Dec Brightness", CV_WINDOW_AUTOSIZE);
imshow("Inc Brightness", imgInc);
imshow("Dec Brightness", imgDec);
//Wait Key press
cvWaitKey(0);
//destroy windows
destroyAllWindows();
return 0;
}
</pre>
<b>OR</b><br />Get <strong>ChangeBrightness.cpp</strong> from Github:
<br />
<a class="btn btn-info" href="https://github.com/iamrachitgulati/image-filter" rel="nofollow" role="button" target="_blank">Download ChangeBrightness.cpp</a>
</div>
<br />
<li>Paste full source code and Run it (Ctrl+F5 or F5).</li>
<br />
</ol>
<b>OUTPUT</b><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-7JzPEdMuRHnmHGYj-u_M4pcwSIEEOESblUijyUKdKLkIrF8iSUvmcGwg7N-wLg4XWfxZkXLd5afCS9px5cUEHh2P8sTV8D3OISSOEO6qBd70EWi5xFbviy81UL_CQ4IB3Vay4tII2Y/s1600/load-image-opencv.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Load an Image OpenCV" border="0" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-7JzPEdMuRHnmHGYj-u_M4pcwSIEEOESblUijyUKdKLkIrF8iSUvmcGwg7N-wLg4XWfxZkXLd5afCS9px5cUEHh2P8sTV8D3OISSOEO6qBd70EWi5xFbviy81UL_CQ4IB3Vay4tII2Y/s400/load-image-opencv.PNG" title="Load an Image OpenCV" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Load Image OpenCV</b></td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbP7d54DqyVFuZ1K3zX7g7cJExEwL-ZJJIoJLwKr2Xdvn8voRLrVy7cHfMs0bSYZ-Hx2f4pm2ngqYnghwZLTocYghDP6HKVqNpCaBbrwCxau6TYtaUDdoCCUXr4Q0fzg4mNJ7W0hyumXs/s1600/increase-brightness-opencv.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Increase Brightness of an Image" border="0" height="218" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbP7d54DqyVFuZ1K3zX7g7cJExEwL-ZJJIoJLwKr2Xdvn8voRLrVy7cHfMs0bSYZ-Hx2f4pm2ngqYnghwZLTocYghDP6HKVqNpCaBbrwCxau6TYtaUDdoCCUXr4Q0fzg4mNJ7W0hyumXs/s400/increase-brightness-opencv.PNG" title="Increase Brightness of an Image" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Increase Brightness of an Image - OpenCV</b></td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuScD6uqE5I4RnDe_S8Fdxupn_bpS3foJjebfZv1G9eer6Z_90LADRNXOYcBhCYAYVk-sQ4dce8VYWi4Y7Y4RD58Btk_Bm1Fpz72QRZLWj9YyOO8IXMW-_qM09RPgUAgO3daJUV7TDqh4/s1600/decrease-brightness-opencv.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Decrease Brightness of an Image" border="0" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuScD6uqE5I4RnDe_S8Fdxupn_bpS3foJjebfZv1G9eer6Z_90LADRNXOYcBhCYAYVk-sQ4dce8VYWi4Y7Y4RD58Btk_Bm1Fpz72QRZLWj9YyOO8IXMW-_qM09RPgUAgO3daJUV7TDqh4/s400/decrease-brightness-opencv.PNG" title="Decrease Brightness of an Image" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Decrease Brightness of an Image - OpenCV</b></td></tr>
</tbody></table>
<br />
<!-- adsense -->
<br />
<b>Explaination :</b><br />
Function used: <br />
img.convertTo(imgInc, -1, 1, 25) - This function can process images and increase brightness by 25 units.
<br />
img.convertTo(imgDec, -1, 1, -25) - This function can process images and decrease brightness by 25 units.<br />
<ul>
<li>1<sup>st</sup> parameter is the output matrix.</li>
<li>2<sup>nd</sup> parameter is Depth of the output image. If rtype is negative, output type is same as the input type.</li>
<li>3<sup>rd</sup> parameter is the multiplication or scaling factor, every pixel will be multiplied by this value.</li>
<li>4<sup>th</sup> parameter is delta factor added to the scaled values.</li>
</ul>
<br />
<hr />
<b>Like, Share and Comment Below.</b>
<b>You may also like this:</b><br />
<br />
<br />
<li><a href="http://opencv-cpp.blogspot.com/2016/11/change-contrast-of-image.html">Change Contrast of an Image</a></li>
<br />
<hr />
</div>
Rachit Gulatihttp://www.blogger.com/profile/13006436391845917580noreply@blogger.com0India20.593684 78.962880000000041-8.5806465 37.654286000000042 49.7680145 120.27147400000004tag:blogger.com,1999:blog-2018586680642679209.post-88042353840331575222016-11-01T14:10:00.000+05:302018-03-30T15:10:56.391+05:30Apply Blur Filter Effect on an Image<div dir="ltr" style="text-align: left;" trbidi="on">
Steps to <b>Apply Blur Filter Effect on an Image | OpenCV with Visual Studio in Windows 10</b>. In this Tutorial, we are going to apply <i>Blur Filter Effect</i> on an image using OpenCV.<br />
<ol>
<li>First of all, Follow this tutorial to <a href="http://opencv-cpp.blogspot.com/2016/10/installing-configuring-opencv-with-visual-studio.html" rel="" target="_blank">Install & Configure OpenCV with Visual Studio 2015</a></li>
<br />
<li>Copy the Full Source Code to Apply Blur Filter on an Image from here:</li>
<div class="tab-content">
<pre>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
using namespace cv;
int main()
{
//Load an Image
Mat img = imread("C:/Briefcase/Chess.jpg", CV_LOAD_IMAGE_COLOR);
namedWindow("Image", CV_WINDOW_AUTOSIZE);
imshow("Image", img);
//Blur Effect
GaussianBlur(img, img, cv::Size(3, 3), 0);
namedWindow("BlurEffect", CV_WINDOW_AUTOSIZE);
imshow("BlurEffect", img);
//Wait Key press
cvWaitKey(0);
//destroy
cvDestroyWindow("Image");
cvDestroyWindow("BlurEffect");
return 0;
}
</pre>
<b>OR</b><br />Get <strong>BlurEffect.cpp</strong> from Github:
<br />
<a class="btn btn-info" href="https://github.com/iamrachitgulati/image-filter" rel="nofollow" role="button" target="_blank">Download BlurEffect.cpp</a>
</div>
<br />
<li>Paste full source code and Run it (Ctrl+F5 or F5).</li>
<br />
</ol>
<b>OUTPUT</b><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-7JzPEdMuRHnmHGYj-u_M4pcwSIEEOESblUijyUKdKLkIrF8iSUvmcGwg7N-wLg4XWfxZkXLd5afCS9px5cUEHh2P8sTV8D3OISSOEO6qBd70EWi5xFbviy81UL_CQ4IB3Vay4tII2Y/s1600/load-image-opencv.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Load an Image OpenCV" border="0" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-7JzPEdMuRHnmHGYj-u_M4pcwSIEEOESblUijyUKdKLkIrF8iSUvmcGwg7N-wLg4XWfxZkXLd5afCS9px5cUEHh2P8sTV8D3OISSOEO6qBd70EWi5xFbviy81UL_CQ4IB3Vay4tII2Y/s400/load-image-opencv.PNG" title="Load an Image OpenCV" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Load Image OpenCV</b></td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu4VAkSmEzLUwQ5qp_Gi1HTbNjr4Yg4gQLxs42xKU1-bR2utgr9xtN-8Ov5yvW5tjXVjHmSiQDbpbVcdgxCXio4Z0RMHnPIumJh2-GT5NmsgBkQPqOg2rRsjvDlh6eYKxBSVUVUscYCFk/s1600/blur-effect-opencv.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Blur Filter Effect OpenCV" border="0" height="218" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu4VAkSmEzLUwQ5qp_Gi1HTbNjr4Yg4gQLxs42xKU1-bR2utgr9xtN-8Ov5yvW5tjXVjHmSiQDbpbVcdgxCXio4Z0RMHnPIumJh2-GT5NmsgBkQPqOg2rRsjvDlh6eYKxBSVUVUscYCFk/s400/blur-effect-opencv.PNG" title="Blur Filter Effect OpenCV" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Blur Image OpenCV</b></td></tr>
</tbody></table>
<br />
<!-- adsense -->
<br />
<b>Explaination :</b> Function used: GaussianBlur(img, img, cv::Size(3, 3), 0) - This function can process images and blur an image.<br />
<ul>
<li>1<sup>st</sup> parameter is the source image.</li>
<li>2<sup>nd</sup> parameter is the destination or resultant image which is a blur image.</li>
<li>3<sup>rd</sup> parameter is the structuring element used.</li>
<li>4<sup>th</sup> parameter is gaussian standard deviation in x direction (sigmaX)</li>
</ul>
<br />
<hr />
<b>Like, Share and Comment Below.</b>
<b>You may also like these:</b><br />
<br />
<br />
<li><a href="http://opencv-cpp.blogspot.com/2016/11/erode-filter-effect-on-image.html">Apply Erode Filter Effect on an Image</a></li>
<li><a href="http://opencv-cpp.blogspot.com/2016/11/dilate-filter-effect-on-image.html">Apply Dilate Filter Effect on an Image</a></li>
<li><a href="http://opencv-cpp.blogspot.com/2016/11/negative-filter-effect-on-image.html">Apply Negative Filter Effect on an Image</a></li>
<br />
<hr />
</div>
Rachit Gulatihttp://www.blogger.com/profile/13006436391845917580noreply@blogger.com2India20.593684 78.962880000000041-8.5806465 37.654286000000042 49.7680145 120.27147400000004tag:blogger.com,1999:blog-2018586680642679209.post-10099366655168167172016-11-01T14:00:00.000+05:302018-03-30T15:10:42.479+05:30Apply Negative Filter Effect on an Image<div dir="ltr" style="text-align: left;" trbidi="on">
Steps to <b>Apply Negative Filter Effect on an Image | OpenCV with Visual Studio in Windows 10</b>. In this Tutorial, we are going to apply <i>Negative Filter Effect</i> on an image using OpenCV.<br />
<ol>
<li>First of all, Follow this tutorial to <a href="http://opencv-cpp.blogspot.com/2016/10/installing-configuring-opencv-with-visual-studio.html" target="_blank">Install & Configure OpenCV with Visual Studio 2015</a></li>
<br />
<li>Copythe Full Source Code to Apply Negative Filter on an Image from here:</li>
<div class="tab-content">
<pre>
#include<opencv2/highgui/highgui.hpp>
#include<iostream>
int main()
{
//Load an Image
IplImage* img = cvLoadImage("C:/Briefcase/Chess.jpg");
cv::namedWindow("Image", CV_WINDOW_AUTOSIZE);
cvShowImage("Image", img);
//Negative Effect
cvNot(img, img);
cv::namedWindow("NegativeEffect", CV_WINDOW_AUTOSIZE);
cvShowImage("NegativeEffect", img);
//Wait Key press
cvWaitKey(0);
//destroy
cvDestroyWindow("Image");
cvDestroyWindow("NegativeEffect");
return 0;
}
</pre>
<b>OR</b><br />Get <strong>NegativeEffect.cpp</strong> from Github:
<br />
<a class="btn btn-info" href="https://github.com/iamrachitgulati/image-filter" rel="nofollow" role="button" target="_blank">Download NegativeEffect.cpp</a>
</div>
<br />
<li>Paste full source code and Run it (Ctrl+F5 or F5).</li>
<br />
</ol>
<b>OUTPUT</b><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-7JzPEdMuRHnmHGYj-u_M4pcwSIEEOESblUijyUKdKLkIrF8iSUvmcGwg7N-wLg4XWfxZkXLd5afCS9px5cUEHh2P8sTV8D3OISSOEO6qBd70EWi5xFbviy81UL_CQ4IB3Vay4tII2Y/s1600/load-image-opencv.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Load an Image OpenCV" border="0" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-7JzPEdMuRHnmHGYj-u_M4pcwSIEEOESblUijyUKdKLkIrF8iSUvmcGwg7N-wLg4XWfxZkXLd5afCS9px5cUEHh2P8sTV8D3OISSOEO6qBd70EWi5xFbviy81UL_CQ4IB3Vay4tII2Y/s400/load-image-opencv.PNG" title="Load an Image OpenCV" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Load Image OpenCV</b></td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1ca3VJHU7Ix_Y2iCd2pOgLva1LgFZkSAks_Q6bSKKz2rOGIr1PoP6Hdm7-ZemxpNw4HbEQ-9vdjcTigNYQb-H2675glVNvq_G_ZgrQKZuJlBsyg1g5b8OEIOetLEGrSG-bu9N5CYnMkI/s1600/negative-effect-opencv.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Negative Filter Effect OpenCV" border="0" height="220" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1ca3VJHU7Ix_Y2iCd2pOgLva1LgFZkSAks_Q6bSKKz2rOGIr1PoP6Hdm7-ZemxpNw4HbEQ-9vdjcTigNYQb-H2675glVNvq_G_ZgrQKZuJlBsyg1g5b8OEIOetLEGrSG-bu9N5CYnMkI/s400/negative-effect-opencv.PNG" title="Negative Filter Effect OpenCV" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Negative Image OpenCV</b></td></tr>
</tbody></table>
<br />
<!-- adsense -->
<br />
<b>Explaination :</b> Function used: cvNot(img, img) - This function can process images and invert every bit elment in an image.<br />
<br />
<ul>
<li>1<sup>st</sup> parameter is the source image.</li>
<li>2<sup>nd</sup> parameter is the destination or resultant image which is a negative image.</li>
</ul>
<br />
<hr />
<b>Like, Share and Comment Below.</b>
<b>You may also like these:</b><br />
<br />
<br />
<br />
<li><a href="http://opencv-cpp.blogspot.com/2016/11/blur-filter-effect-on-image.html">Apply Blur Filter Effect on an Image</a></li>
<li><a href="http://opencv-cpp.blogspot.com/2016/11/erode-filter-effect-on-image.html">Apply Erode Filter Effect on an Image</a></li>
<li><a href="http://opencv-cpp.blogspot.com/2016/11/dilate-filter-effect-on-image.html">Apply Dilate Filter Effect on an Image</a></li>
<br />
<hr />
</div>
Rachit Gulatihttp://www.blogger.com/profile/13006436391845917580noreply@blogger.com0India20.593684 78.962880000000041-8.5806465 37.654286000000042 49.7680145 120.27147400000004tag:blogger.com,1999:blog-2018586680642679209.post-53485671047728534112016-11-01T13:40:00.000+05:302018-03-30T15:10:30.235+05:30Apply Dilate Filter Effect on an Image<div dir="ltr" style="text-align: left;" trbidi="on">
Steps to <b>Apply Dilate Filter Effect on an Image | OpenCV with Visual Studio in Windows 10</b>. In this Tutorial, we are going to apply <i>Dilate Filter Effect</i> on an image using OpenCV.<br />
<ol>
<li>First of all, Follow this tutorial to <a href="http://opencv-cpp.blogspot.com/2016/10/installing-configuring-opencv-with-visual-studio.html" target="_blank">Install & Configure OpenCV with Visual Studio 2015</a></li>
<br />
<li>Copy the Full Source Code to Apply Dilate Filter on an Image from here:</li>
<div class="tab-content">
<pre>
#include<opencv2/highgui/highgui.hpp>
#include<iostream>
int main()
{
//Load an Image
IplImage* img = cvLoadImage("C:/Briefcase/Chess.jpg");
cv::namedWindow("Image",CV_WINDOW_AUTOSIZE);
cvShowImage("Image", img);
//Dilate Effect
cvDilate(img, img, 0, 2);
cv::namedWindow("DilateEffect", CV_WINDOW_AUTOSIZE);
cvShowImage("DilateEffect", img);
//Wait Key press
cvWaitKey(0);
//destroy
cvDestroyWindow("Image");
cvDestroyWindow("DilateEffect");
return 0;
}
</pre>
<b>OR</b><br/>Get <strong>DilateEffect.cpp</strong> from Github:
<br />
<a class="btn btn-info" href="https://github.com/iamrachitgulati/image-filter" rel="nofollow" role="button" target="_blank">Download DilateEffect.cpp</a>
</div>
<br />
<li>Paste full source code and Run it (Ctrl+F5 or F5).</li>
<br />
</ol>
<b>OUTPUT</b><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-7JzPEdMuRHnmHGYj-u_M4pcwSIEEOESblUijyUKdKLkIrF8iSUvmcGwg7N-wLg4XWfxZkXLd5afCS9px5cUEHh2P8sTV8D3OISSOEO6qBd70EWi5xFbviy81UL_CQ4IB3Vay4tII2Y/s1600/load-image-opencv.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Load an Image OpenCV" border="0" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-7JzPEdMuRHnmHGYj-u_M4pcwSIEEOESblUijyUKdKLkIrF8iSUvmcGwg7N-wLg4XWfxZkXLd5afCS9px5cUEHh2P8sTV8D3OISSOEO6qBd70EWi5xFbviy81UL_CQ4IB3Vay4tII2Y/s400/load-image-opencv.PNG" title="Load an Image OpenCV" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Load Image OpenCV</b></td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg67lU148y6q-7lBzJ1zI6CT5bfd490egFabJInY_eSsztPoisVrF_2UqmZbePVLz8oMBTR_cS9gg8zFfHBvCTsoHru2ZIIqtytTVk8LvIbsAjM2F1IstsH385E5-ysU9Zs8bmD2fQVHbs/s1600/dilate-effect-opencv.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Dilate Filter Effect OpenCV" border="0" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg67lU148y6q-7lBzJ1zI6CT5bfd490egFabJInY_eSsztPoisVrF_2UqmZbePVLz8oMBTR_cS9gg8zFfHBvCTsoHru2ZIIqtytTVk8LvIbsAjM2F1IstsH385E5-ysU9Zs8bmD2fQVHbs/s400/dilate-effect-opencv.PNG" title="Dilate Filter Effect OpenCV" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Dilated Image OpenCV</b></td></tr>
</tbody></table>
<br />
<!-- adsense -->
<br />
<b>Explaination :</b> Function used: cvDilate(img, img, 0, 2) - This function can process images and dilate an image.<br />
<ul>
<li>1<sup>st</sup> parameter is the source image.</li>
<li>2<sup>nd</sup> parameter is the destination or resultant image which is a dilated image.</li>
<li>3<sup>rd</sup> parameter is the structuring element used. If it is 0, a 3 X 3 rectangular structuring element is used.</li>
<li>4<sup>th</sup> parameter is the number of times, effect is applied.</li>
</ul>
<br />
<hr />
<b>Like, Share and Comment Below.</b>
<b>You may also like these:</b><br />
<br />
<br />
<br />
<li><a href="http://opencv-cpp.blogspot.com/2016/11/blur-filter-effect-on-image.html">Apply Blur Filter Effect on an Image</a></li>
<li><a href="http://opencv-cpp.blogspot.com/2016/11/erode-filter-effect-on-image.html">Apply Erode Filter Effect on an Image</a></li>
<li><a href="http://opencv-cpp.blogspot.com/2016/11/negative-filter-effect-on-image.html">Apply Negative Filter Effect on an Image</a></li>
<br />
<hr />
</div>
Rachit Gulatihttp://www.blogger.com/profile/13006436391845917580noreply@blogger.com1India20.593684 78.962880000000041-8.5806465 37.654286000000042 49.7680145 120.27147400000004tag:blogger.com,1999:blog-2018586680642679209.post-65749318295616103932016-11-01T13:18:00.000+05:302018-03-30T15:10:16.436+05:30Apply Erode Filter Effect on an Image<div dir="ltr" style="text-align: left;" trbidi="on">
Steps to <b>Apply Erode Filter Effect on an Image | OpenCV with Visual Studio in Windows 10</b>. In this Tutorial, we are going to apply <i>Erode Filter Effect</i> on an image using OpenCV.<br />
<ol>
<li>First of all, Follow this tutorial to <a href="http://opencv-cpp.blogspot.com/2016/10/installing-configuring-opencv-with-visual-studio.html" target="_blank">Install & Configure OpenCV with Visual Studio 2015</a></li>
<br />
<li>Copy the Full Source Code to Apply Erode Filter on an Image from here:</li>
<div class="tab-content">
<pre>#include<opencv2/highgui/highgui.hpp>
#include<iostream>
int main()
{
//Load an Image
IplImage* img = cvLoadImage("C:/Briefcase/Chess.jpg");
cv::namedWindow("Image", CV_WINDOW_AUTOSIZE);
cvShowImage("Image", img);
//Erode Effect
cvErode(img, img, 0, 2);
cv::namedWindow("ErodeEffect", CV_WINDOW_AUTOSIZE);
cvShowImage("ErodeEffect", img);
//Wait Key press
cvWaitKey(0);
//destroy
cvDestroyWindow("Image");
cvDestroyWindow("ErodeEffect");
return 0;
}
</pre>
<b>OR</b><br />
Get <b>ErodeEffect.cpp</b> from Github:
<br />
<a class="btn btn-info" href="https://github.com/iamrachitgulati/image-filter" rel="nofollow" role="button" target="_blank">Download ErodeEffect.cpp</a>
</div>
<br />
<li>Paste full source code and Run it (Ctrl+F5 or F5).</li>
</ol>
<br />
<b>OUTPUT </b><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-7JzPEdMuRHnmHGYj-u_M4pcwSIEEOESblUijyUKdKLkIrF8iSUvmcGwg7N-wLg4XWfxZkXLd5afCS9px5cUEHh2P8sTV8D3OISSOEO6qBd70EWi5xFbviy81UL_CQ4IB3Vay4tII2Y/s1600/load-image-opencv.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Load an Image OpenCV" border="0" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2-7JzPEdMuRHnmHGYj-u_M4pcwSIEEOESblUijyUKdKLkIrF8iSUvmcGwg7N-wLg4XWfxZkXLd5afCS9px5cUEHh2P8sTV8D3OISSOEO6qBd70EWi5xFbviy81UL_CQ4IB3Vay4tII2Y/s400/load-image-opencv.PNG" title="Load an Image OpenCV" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Load Image OpenCV</b></td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBJbhqEz4D1FLYRddVEStBXaDy5vrvr1nvxKQ8dMvw8VlOwk-Q4lI_6avmAVihB3D2Rh_UA9oNVCbzHjfitOpL4ZPOJBtcgxDFw_t7Y0Zb5_8ltdQFIN8FfbYK3SHMuLVLv8d0s-arpMw/s1600/erode-effect-opencv.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Erode Filter Effect OpenCV" border="0" height="218" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBJbhqEz4D1FLYRddVEStBXaDy5vrvr1nvxKQ8dMvw8VlOwk-Q4lI_6avmAVihB3D2Rh_UA9oNVCbzHjfitOpL4ZPOJBtcgxDFw_t7Y0Zb5_8ltdQFIN8FfbYK3SHMuLVLv8d0s-arpMw/s400/erode-effect-opencv.PNG" title="Erode Filter Effect OpenCV" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>Eroded Image OpenCV</b></td></tr>
</tbody></table>
<br />
<!-- adsense -->
<br />
<b>Explaination :</b> Function used: cvErode(img, img, 0, 2) - This function can process images and erode an image.<br />
<br />
<ul>
<li>1<sup>st</sup> parameter is the source image.</li>
<li>2<sup>nd</sup> parameter is the destination or resultant image which is an eroded image.</li>
<li>3<sup>rd</sup> parameter is the structuring element used. If it is 0, a 3 X 3 rectangular structuring element is used.</li>
<li>4<sup>th</sup> parameter is the number of times, effect is applied.</li>
</ul>
<br />
<hr />
<b>Like, Share and Comment Below.</b>
<b>You may also like these:</b><br />
<br />
<br />
<br />
<br />
<li><a href="http://opencv-cpp.blogspot.com/2016/11/blur-filter-effect-on-image.html">Apply Blur Filter Effect on an Image</a></li>
<li><a href="http://opencv-cpp.blogspot.com/2016/11/dilate-filter-effect-on-image.html">Apply Dilate Filter Effect on an Image</a></li>
<li><a href="http://opencv-cpp.blogspot.com/2016/11/negative-filter-effect-on-image.html">Apply Negative Filter Effect on an Image</a></li>
<br />
<hr />
</div>
Rachit Gulatihttp://www.blogger.com/profile/13006436391845917580noreply@blogger.com2India20.593684 78.962880000000041-8.5806465 37.654286000000042 49.7680145 120.27147400000004tag:blogger.com,1999:blog-2018586680642679209.post-15794809188609792252016-10-31T16:36:00.000+05:302018-03-30T15:09:47.229+05:30Object Detection and Tracking using Color Separation<div dir="ltr" style="text-align: left;" trbidi="on">
Steps for <b>Object Detection & Tracking | OpenCV with Visual Studio in Windows 10</b>. In this Tutorial, we are going to <i>Detect and Track a Yellow Ball using Object Detection</i> (Color Separation) OpenCV.<br />
<ol>
<li>First of all, Follow this tutorial to <a href="http://opencv-cpp.blogspot.com/2016/10/installing-configuring-opencv-with-visual-studio.html" target="_blank">Install & Configure OpenCV with Visual Studio 2015</a></li>
<br />
<li>Copy the Full Source Code for Object Detection and Tracking from here:</li>
<div class="tab-content">
<pre>#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
/*
TRACK A YELLOW BALL - OBJECT DETECTION METHOD USING COLOR SEPERATION OPEN CV 3.1.0
author - Rachit Gulati
*/
int main() {
cv::VideoCapture capWebcam(0); // declare a VideoCapture object to associate webcam, 0 means use 1st (default) webcam
if (capWebcam.isOpened() == false) // To check if object was associated to webcam successfully
{
std::cout << "error: Webcam connect unsuccessful\n"; // if not then print error message
return(0); // and exit program
}
cv::Mat imgOriginal; // Input image
cv::Mat hsvImg; // HSV Image
cv::Mat threshImg; // Thresh Image
std::vector<cv::vec3f> v3fCircles; // 3 element vector of floats, this will be the pass by reference output of HoughCircles()
char charCheckForEscKey = 0;
int lowH = 21; // Set Hue
int highH = 30;
int lowS = 200; // Set Saturation
int highS = 255;
int lowV = 102; // Set Value
int highV = 225;
// HUE for YELLOW is 21-30.
// Adjust Saturation and Value depending on the lighting condition of the environment as well as the surface of the object.
while (charCheckForEscKey != 27 && capWebcam.isOpened()) { // until the Esc is pressed or webcam connection is lost
bool blnFrameReadSuccessfully = capWebcam.read(imgOriginal); // get next frame
if (!blnFrameReadSuccessfully || imgOriginal.empty()) { // if frame read unsuccessfully
std::cout << "error: frame can't read \n"; // print error message
break; // jump out of loop
}
cv::cvtColor(imgOriginal, hsvImg, CV_BGR2HSV); // Convert Original Image to HSV Thresh Image
cv::inRange(hsvImg, cv::Scalar(lowH, lowS, lowV), cv::Scalar(highH, highS, highV), threshImg);
cv::GaussianBlur(threshImg, threshImg, cv::Size(3, 3), 0); //Blur Effect
cv::dilate(threshImg, threshImg, 0); // Dilate Filter Effect
cv::erode(threshImg, threshImg, 0); // Erode Filter Effect
// fill circles vector with all circles in processed image
cv::HoughCircles(threshImg,v3fCircles,CV_HOUGH_GRADIENT,2,threshImg.rows / 4,100,50,10,800); // algorithm for detecting circles
for (int i = 0; i < v3fCircles.size(); i++) { // for each circle
std::cout << "Ball position X = "<< v3fCircles[i][0] // x position of center point of circle
<<",\tY = "<< v3fCircles[i][1] // y position of center point of circle
<<",\tRadius = "<< v3fCircles[i][2]<< "\n"; // radius of circle
// draw small green circle at center of object detected
cv::circle(imgOriginal, // draw on original image
cv::Point((int)v3fCircles[i][0], (int)v3fCircles[i][1]), // center point of circle
3, // radius of circle in pixels
cv::Scalar(0, 255, 0), // draw green
CV_FILLED); // thickness
// draw red circle around object detected
cv::circle(imgOriginal, // draw on original image
cv::Point((int)v3fCircles[i][0], (int)v3fCircles[i][1]), // center point of circle
(int)v3fCircles[i][2], // radius of circle in pixels
cv::Scalar(0, 0, 255), // draw red
3); // thickness
}
// declare windows
cv::namedWindow("imgOriginal", CV_WINDOW_AUTOSIZE);
cv::namedWindow("threshImg", CV_WINDOW_AUTOSIZE);
/* Create trackbars in "threshImg" window to adjust according to object and environment.*/
cv::createTrackbar("LowH", "threshImg", &lowH, 179); //Hue (0 - 179)
cv::createTrackbar("HighH", "threshImg", &highH, 179);
cv::createTrackbar("LowS", "threshImg", &lowS, 255); //Saturation (0 - 255)
cv::createTrackbar("HighS", "threshImg", &highS, 255);
cv::createTrackbar("LowV", "threshImg", &lowV, 255); //Value (0 - 255)
cv::createTrackbar("HighV", "threshImg", &highV, 255);
cv::imshow("imgOriginal", imgOriginal); // show windows
cv::imshow("threshImg", threshImg);
charCheckForEscKey = cv::waitKey(1); // delay and get key press
}
return(0);
}
</cv::vec3f></pre>
<b>OR</b><br />Get <b>ObjectTracker.cpp</b> from Github:
<br />
<a class="btn btn-info" href="https://github.com/iamrachitgulati/object-tracker" rel="nofollow" role="button">Download ObjectTracker.cpp</a>
</div>
<br />
<li>Paste full source code and Run it (Ctrl+F5 or F5).</li>
</ol>
<u><b>OUTPUT</b></u><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDPS39UHfTAsDl4vf6T47oPeLz6W5MQkbfP3LWYFAmmLUnMwBhSm2Ik0hWQD8fS9Id7jh7ZJcaAvgw3vSnkQ8pd6u7WBIJ-dBnBa-WDXDoF6zxG7l88TJm8deUHBWuunGNeSrZRB1Vo5E/s1600/opencv-object-detection.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Yellow Ball Detection using Color Separation" border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDPS39UHfTAsDl4vf6T47oPeLz6W5MQkbfP3LWYFAmmLUnMwBhSm2Ik0hWQD8fS9Id7jh7ZJcaAvgw3vSnkQ8pd6u7WBIJ-dBnBa-WDXDoF6zxG7l88TJm8deUHBWuunGNeSrZRB1Vo5E/s400/opencv-object-detection.PNG" title="Yellow Ball Detection and Tracking" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Yellow Ball Detection and Tracker OpenCV</td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdLlCH9oPKHexx2SBM4iQ9NylTS4sBeQpMtmAGGb0VogAT0AcIPWG7Xi2zhQygqzGWHwHjfZywWIRl1giRNVVY-XEcbwoSTmS1IvGCEoz6QIIK16oHCZQgOgmc_Dg561KadV4Vnv5h5Q0/s1600/opencv-threshold-img.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Yellow Ball Threshold Image" border="0" height="238" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdLlCH9oPKHexx2SBM4iQ9NylTS4sBeQpMtmAGGb0VogAT0AcIPWG7Xi2zhQygqzGWHwHjfZywWIRl1giRNVVY-XEcbwoSTmS1IvGCEoz6QIIK16oHCZQgOgmc_Dg561KadV4Vnv5h5Q0/s400/opencv-threshold-img.PNG" title="Object Detection Threshold Image" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Yellow Ball Threshold Image</td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_QG6id_1BesV8AWSk2sXWk8hmpxKA4jNXt5AqttlvzBOwVkID_zlqTstIMVxybjqKXjrF8h9CLVLmNIBFZxRum75uSTRmqJWT79i1EWFfPM6OjrZ3QtDdA-XpeBpdTIycS6apq2L8KJw/s1600/object-detection-x-y-coord.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Coordinates and Radius of Yellow Ball" border="0" height="121" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_QG6id_1BesV8AWSk2sXWk8hmpxKA4jNXt5AqttlvzBOwVkID_zlqTstIMVxybjqKXjrF8h9CLVLmNIBFZxRum75uSTRmqJWT79i1EWFfPM6OjrZ3QtDdA-XpeBpdTIycS6apq2L8KJw/s400/object-detection-x-y-coord.JPG" title="Detection with Coordinates of Object" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">X-Coord, Y-Coord and Radius Of Yellow Ball</td></tr>
</tbody></table>
<br />
<!-- adsense -->
<br />
<b>Explaination:</b> You can use trackbars in "threshImg" window to adjust Hue, Saturation, Value according to object and environment(lightning), Hue values of basic colors:<br />
<br />
<ul>
<li><i>Yellow 21- 30</i></li>
<i>
</i>
<li><i>Blue 75-130</i></li>
<i>
</i>
<li><i>Violet 130-160</i></li>
<i>
</i>
<li><i>Orange 0-21</i></li>
<i>
</i>
<li><i>Green 38-75</i></li>
<i>
</i>
<li><i>Red 160-179</i></li>
</ul>
You have to find the exact range of HUE values according to the color of the object. The SATURATION and VALUE is depend on the lighting condition of the environment as well as the surface of the object.<br />
<br />
<hr />
<b>Like, Share and Comment Below</b>
<br />
<hr />
</div>
Rachit Gulatihttp://www.blogger.com/profile/13006436391845917580noreply@blogger.com9India20.593684 78.962880000000041-8.5806465 37.654286000000042 49.7680145 120.27147400000004tag:blogger.com,1999:blog-2018586680642679209.post-31857277222947337672016-10-30T17:12:00.002+05:302018-03-30T15:09:12.361+05:30Installing & Configuring with Visual Studio<div dir="ltr" style="text-align: left;" trbidi="on">
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6OvtikG5wWp0COPTvYHcGvjv7diJV5LJzHOssWCdwsjzw4ACoxZ8-Db1vD-iJvEcbmAh44APqQL96J5plAqYOGPpcRm5X6Kdhb82c8Wb5OtdTDcAACGSdW6E7rX6p-6eS1xN7FXH22gk/s1600/opencv-visual-studio-tutorial.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Installing Opencv c++ tutorial" border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6OvtikG5wWp0COPTvYHcGvjv7diJV5LJzHOssWCdwsjzw4ACoxZ8-Db1vD-iJvEcbmAh44APqQL96J5plAqYOGPpcRm5X6Kdhb82c8Wb5OtdTDcAACGSdW6E7rX6p-6eS1xN7FXH22gk/s640/opencv-visual-studio-tutorial.png" title="Installing and Configure OpenCV with Visual Studio" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><b>How to Install And Configure OpenCV with Visual Studio</b></td></tr>
</tbody></table>
Steps for Installing & Configuring OpenCV with Visual Studio in Windows 10. Using:<br />
<ul>
<i>
<li>Windows 10 64-bit</li>
<li>Visual Studio Community Edition 2015 Update 1</li>
<li>OpenCv 3.1.0</li>
</i>
</ul>
<ol>
<li style="text-align: justify;">Download and <b>install Visual Studio 2015</b> Community Edition. It's free and choosing all default option including VC++ will work fine.</li>
<br />
<li><b>Download latest version of OpenCV</b>. I am using OpenCV 3.1.0</li>
<br />
<li>Make a folder of your OpenCV version.<i> for example "C:\OpenCV-3.1.0"</i></li>
<br />
<li>Add the bin directory of OpenCV to the operating system path.<br />
a) Go to: System Properties -> Advanced Sytem Settings -> Environment Variables -> Edit Path Variable<br />
b) Add new path value to <i>"C:\OpenCV-3.1.0\opencv\build\x64\vc14\bin" and Apply Changes.</i></li>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4PGZiVp2kkwBMfswl5pjpnyAI16BA0waU1XA4XkPsUacUcCCsVWkfGwReZ2oGATsuZ0uywfZD8AbFiag6iBVhyphenhyphenV_NIk3i_HqCWkncknMt43G85_N7kPLwJbUeut13ixNuIkJ3kmvZ7jI/s1600/advanced-system-properties.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="OpenCV Advanced System Settings" border="0" height="297" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4PGZiVp2kkwBMfswl5pjpnyAI16BA0waU1XA4XkPsUacUcCCsVWkfGwReZ2oGATsuZ0uywfZD8AbFiag6iBVhyphenhyphenV_NIk3i_HqCWkncknMt43G85_N7kPLwJbUeut13ixNuIkJ3kmvZ7jI/s400/advanced-system-properties.PNG" title="OpenCV Advanced System Settings" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnL1judVV5NPrUOkibmZtXUSzz28cYhbTbsqtJg_IckhEuq4zfd_kdKwn1StDMpG2y71wc_Y6MdoozPSsgVFTk3SsAmgVRtBIScEj_WayBl68q9R7Tla4wzdx4A_EckDpkEc1WN4jP1YI/s1600/opencv-environment-settings.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="OpenCV Environment Path Setup" border="0" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnL1judVV5NPrUOkibmZtXUSzz28cYhbTbsqtJg_IckhEuq4zfd_kdKwn1StDMpG2y71wc_Y6MdoozPSsgVFTk3SsAmgVRtBIScEj_WayBl68q9R7Tla4wzdx4A_EckDpkEc1WN4jP1YI/s400/opencv-environment-settings.PNG" title="OpenCV Environment Path Setup" width="400" /></a></div>
<br />
<li><b>Start Visual Studio</b>, choose File->New->Project</li>
<br />
<!-- adsense -->
<br />
<li>Choose Visual C++, <b>Empty Project</b>, name your project, example "Test", Set preferred location, uncheck "Create directory for solution" and "Add to source control", Choose Ok.</li>
<br />
<li>Right Click in Solution Explorer,Choose Add -> New Item. Choose "C++ File", name the file, example "ObjectTracking.cpp". Choose Add.</li>
<br />
<li>In the Visual Studio toolbar, verify that <b>"Solution Configurations" is set to "Debug"</b>, then change <b>"Solution Platforms" to "x64"</b></li>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguXph9iKmbYjg_Y4NBc_jgOVSzDuya6dOaf5FhrfOv0YVYcTfyhZXFrbKZI6wYBTS29SL1bmGs_1aWJYHoC1TeGR9owCbRc8nMLnSheXVoL2FcdBcqeyC_-sAixMIV6i4ozRsZRreZcLQ/s1600/VS-debug-x64.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="OpenCv Visual Studio Debug x64 " border="0" height="53" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguXph9iKmbYjg_Y4NBc_jgOVSzDuya6dOaf5FhrfOv0YVYcTfyhZXFrbKZI6wYBTS29SL1bmGs_1aWJYHoC1TeGR9owCbRc8nMLnSheXVoL2FcdBcqeyC_-sAixMIV6i4ozRsZRreZcLQ/s400/VS-debug-x64.PNG" title="OpenCv Visual Studio Debug x64" width="400" /></a></div>
<br />
<li><b>In VS 2015 go to:</b><br />
a) Project -> (project name) Properties -> Configuration Properties -> VC++ Directories -> Include Directories add the include directory for your version of OpenCV,<i> ex "C:\OpenCV-3.1.0\opencv\build\include"</i><br />
b) Project -> Properties -> Configuration Properties -> VC++ Directories -> Library Directories: add the library directory for your version of OpenCV,<i> ex "C:\OpenCV-3.1.0\opencv\build\x64\vc14\lib"</i><br />
c) Project -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies: Copy/paste the name of the debug lib(s) in the lib directory,<i> ex "opencv_world310d.lib"</i></li>
<br />
<li>Done ! You are ready to write code and Run your program. </li>
</ol>
<div style="text-align: right;">
<a href="http://opencv-cpp.blogspot.com/2016/10/opencv-tutorial.html" target="_blank">>>MORE OPENCV C++ TUTORIALS</a> </div>
<hr />
<b>Like, Share and Comment Below</b>
<br />
<hr />
</div>
Rachit Gulatihttp://www.blogger.com/profile/13006436391845917580noreply@blogger.com6India20.593684 78.962880000000041-8.5806465 37.654286000000042 49.7680145 120.27147400000004