How to create .exe project of dot net (C#) of MS Access Data Base.

If you want to create .exe Setup Project of your **Dot Net** Application which is using **MS Access DATA BASES**. then simply follow this steps. Please read this one for a moment before to proceed these steps.[Connect with MS Access Data Base in Dot net][1].
When you are going to create the exe file then your data base connection string should be like this(means there should be no directory in @”Data source, Just direct put the name of your data base, because in .exe file when you add your data base file, then it is in the same directory.

System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
      conn.ConnectionString = @”Provider=Microsoft.ACE.OLEDB.12.0;” +
      @”Data source=MyDataBase.accdb”;

1. Right click on your solution file. *(like in Solution Explorer “Solution ‘MyProject’ “)*
2. Select Add –>New Project –>Other Project Types
3. Select “Setup”
4. A New project will be added named setup (*with a new tab added to
editor as File System )*
5. Now right click on application folder –>select add –>select folder
new folder will be added under application folder * Now Right click
on newly added folder –>select add –>select file * Add File dialog
will be popup
6. Select your Db file *(means from a “Browse” Button there go and select your Access Data Base )*
7. Select Setup project and build.. Now your
installer will have your DB.

Some screen shot which will help you

Step 1 picture:

Step2 Picture:





Detection of Face in Open CV, simple method

As i also have uploaded the “detection of face and eye”  tutorial but now at this time, i am only discussing the “Detection of Face”. The code given below is well commented. So just copy it your project, and it will work 100%.

This program will detect the face of each person from the picture. For this you also have to upload the “haarcascade xml file”
because in this xml file all the data is available about different faces, so you will got a rectangel drawn at accurate face
using namespace cv;
using namespace std;

int main()
CascadeClassifier cascade;

// this will upload the “haarcascade xml file”…
if (!cascade.load(“C:\\opencv/data/haarcascades/haarcascade_frontalface_alt.xml”))
printf(“XML file loading is missing !\nSo, you will not be able to detect the faces in the pic”);

//uploading the pic
Mat src = imread(“C:\\images/batch8.jpg”,1);
if (src.empty())
printf(“Image is not upload successfully!”);

Mat gray;
cvtColor(src, gray, CV_BGR2GRAY);
equalizeHist(gray, gray);

vector<Rect> faces;
cascade.detectMultiScale(gray, faces, 1.2, 3);

for (int i = 0; i < faces.size(); i++)//size will show that how many faces have been detecte, if there is an image with two person size =2
//printf(“X & Y position of Rect are: %d,%d\n”,faces[i].x,faces[i].y);
Rect r = faces[i];
rectangle(src, Point(r.x, r.y), Point(r.x + r.width, r.y + r.height), CV_RGB(0,0,255));
printf(“Area of Rect %d is %d\n”,i,(r.width*r.height));

imshow(“src”, src);
return 0;

The Result of this code should be like this:


Detect face and Eye through CAM in Open CV

This tutorial will explain you that how to detect the human face and eyes, when a CAM is open Up and it start video.Here in this tutorial you will get the circle around human face and ellipse around the eye using OPEN CV programming.

#include “opencv2/objdetect/objdetect.hpp”
#include “opencv2/highgui/highgui.hpp”
#include “opencv2/imgproc/imgproc.hpp”

#include <iostream>
#include <stdio.h>

using namespace std;
using namespace cv;

/** Function Headers */
void detectAndDisplay( Mat frame );

/** Global variables */
String face_cascade_name = “C:\\opencv/data/haarcascades/haarcascade_frontalface_alt.xml”;
String eyes_cascade_name = “C:\\opencv/data/haarcascades/haarcascade_eye_tree_eyeglasses.xml”;
CascadeClassifier face_cascade;
CascadeClassifier eyes_cascade;
string window_name = “Capture – Face detection”;
RNG rng(12345);

/** @function main */
int main( int argc, const char** argv )
CvCapture* capture;
Mat frame;

//– 1. Load the cascades
if( !face_cascade.load( face_cascade_name ) ){ printf(“–(!)Error loading\n”); return -1; };
if( !eyes_cascade.load( eyes_cascade_name ) ){ printf(“–(!)Error loading\n”); return -1; };

//– 2. Read the video stream
capture = cvCaptureFromCAM( -1 );
if( capture )
while( true )
frame = cvQueryFrame( capture );
//– 3. Apply the classifier to the frame
if( !frame.empty() )
{ detectAndDisplay( frame ); }
{ printf(” –(!) No captured frame — Break!”); break; }

int c = waitKey(10);
if( (char)c == ‘c’ ) { break; }
return 0;

/** @function detectAndDisplay */
void detectAndDisplay( Mat frame )
std::vector<Rect> faces;
Mat frame_gray;

cvtColor( frame, frame_gray, CV_BGR2GRAY );
equalizeHist( frame_gray, frame_gray );

//– Detect faces
face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) );

for( int i = 0; i < faces.size(); i++ )
Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
ellipse( frame, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 0, 0, 255 ), 4, 8, 0 );

Mat faceROI = frame_gray( faces[i] );
std::vector<Rect> eyes;

//– In each face, detect eyes
eyes_cascade.detectMultiScale( faceROI, eyes, 1.1, 2, 0 |CV_HAAR_SCALE_IMAGE, Size(30, 30) );

for( int j = 0; j < eyes.size(); j++ )
Point center( faces[i].x + eyes[j].x + eyes[j].width*0.5, faces[i].y + eyes[j].y + eyes[j].height*0.5 );
int radius = cvRound( (eyes[j].width + eyes[j].height)*0.25 );
circle( frame, center, radius, Scalar( 255, 0, 0 ), 4, 8, 0 );
//– Show what you got
imshow( window_name, frame );


and the result which i got is some thing like this:


How to set Image for different HSV value in Open CV?

I want to show you that how to get different action of  HSV value on your image. Here in this tutorial we will have two windows one window will show the CAM video, means the picture which through web cam we are getting from surrounding and another window is the combination of resultant picture from HSV value.

//This progam will find out the HSV value for the given image

#include <cv.h>
#include <highgui.h>

int lowerH=0;
int lowerS=0;
int lowerV=0;

int upperH=180;
int upperS=256;
int upperV=256;

//This function threshold the HSV image and create a binary image
IplImage* GetThresholdedImage(IplImage* imgHSV){

IplImage* imgThresh=cvCreateImage(cvGetSize(imgHSV),IPL_DEPTH_8U, 1);
cvInRangeS(imgHSV, cvScalar(lowerH,lowerS,lowerV), cvScalar(upperH,upperS,upperV), imgThresh);

return imgThresh;

//This function create two windows and 6 trackbars for the “Ball” window

void setwindowSettings()

cvCreateTrackbar(“LowerH”, “Ball”, &lowerH, 180, NULL);
cvCreateTrackbar(“UpperH”, “Ball”, &upperH, 180, NULL);

cvCreateTrackbar(“LowerS”, “Ball”, &lowerS, 256, NULL);
cvCreateTrackbar(“UpperS”, “Ball”, &upperS, 256, NULL);

cvCreateTrackbar(“LowerV”, “Ball”, &lowerV, 256, NULL);
cvCreateTrackbar(“UpperV”, “Ball”, &upperV, 256, NULL);

int main(){
CvCapture* capture =0;

capture = cvCaptureFromCAM(0);
printf(“Capture failure\n”);
return -1;

IplImage* frame=0;


//iterate through each frames of the video

frame = cvQueryFrame(capture);
if(!frame) break;

IplImage* imgHSV = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 3);
cvCvtColor(frame, imgHSV, CV_BGR2HSV); //Change the color format from BGR to HSV

IplImage* imgThresh = GetThresholdedImage(imgHSV);

cvShowImage(“Ball”, imgThresh);
cvShowImage(“Video”, frame);

//Clean up used images

//Wait 80mS
int c = cvWaitKey(80);
//If ‘ESC’ is pressed, break the loop
if((char)c==27 ) break;



return 0;



Tracking an Object(Blue Colour) in Open CV

If you want to track a blue color Object using open cv, then this tutorial will help you in understanding the step wise method use for identification and recognition a blue color Object.

// TrackColour.cpp : Defines the entry point for the console application.

#include “highgui.h”
#include <cv.h>
using namespace cv;

IplImage* GetThresholdedImage(IplImage* img)
// Convert the image into an HSV image
IplImage* imgHSV = cvCreateImage(cvGetSize(img), 8, 3);
cvCvtColor(img, imgHSV, CV_BGR2HSV);

IplImage* imgThreshed = cvCreateImage(cvGetSize(img), 8, 1);

// Values 20,100,100 to 30,255,255 working perfect for yellow at around 6pm
cvInRangeS(imgHSV, cvScalar(112, 100, 100), cvScalar(124, 255, 255), imgThreshed);//this will not recognize the yellow color

return imgThreshed;

int main()
// Initialize capturing live feed from the camera
CvCapture* capture = 0;
capture = cvCaptureFromCAM(0);

// Couldn’t get a device? Throw an error and quit
printf(“Could not initialize capturing…\n”);
return -1;
// the tracked positions of the ball
IplImage* imgScribble = NULL;

// An infinite loop
// Will hold a frame captured from the camera
IplImage* frame = 0;
frame = cvQueryFrame(capture);
// If we couldn’t grab a frame… quit

// If this is the first frame, we need to initialize it

imgScribble = cvCreateImage(cvGetSize(frame), 8, 3);//we are resfreshing it agian and again so that the circle draw from previous fram should not be availble with the new one circle

// Holds the yellow thresholded image (yellow = white, rest = black)
IplImage* imgYellowThresh = GetThresholdedImage(frame);

// Calculate the moments to estimate the position of the ball
CvMoments *moments = (CvMoments*)malloc(sizeof(CvMoments));
cvMoments(imgYellowThresh, moments, 1);

// The actual moment values
double moment10 = cvGetSpatialMoment(moments, 1, 0);
double moment01 = cvGetSpatialMoment(moments, 0, 1);
double area = cvGetCentralMoment(moments, 0, 0);

// Holding the last and current ball positions
static int posX = 0;
static int posY = 0;
int lastX = posX;
int lastY = posY;
posX = moment10/area;
posY = moment01/area;
//preparing the color of the circle
CvScalar blue = CV_RGB(0,0,250);
CvPoint pt2 = cvPoint(posX,posY);
cvCircle(imgScribble,pt2,30,blue,2,8);//draw a circle

// Add fram from CAM and the empty image where we are drawing the line
cvAdd(frame, imgScribble, frame);
cvShowImage(“video”, frame);//if we write “imgScribble” here then we will got an empty image screen where line will draw.

// Wait for a keypress
int c = cvWaitKey(10);
if(c==27)//if i press “escape” key
// Release the thresholded image… we need no memory leaks.. please

delete moments;

// We’re done using the camera. Other applications can now use it
return 0;

and the result which i got :


Drawing Rectangle,Circle and Text on the image in OPEN CV

This tutorial will help you in learning, how to draw circle, rectangle, text and line on any image in Open CV.

using namespace cv;

int main()
// Line variables
CvPoint pt1 = cvPoint(250,60);
CvPoint pt2 = cvPoint(405,195);
CvScalar red = CV_RGB(250,0,0);//RGB=250,0,0 thats why we are getting RED
int thickness = 2;
int connectivity = 8;

// Circle variables
int radius = 30;
CvScalar blue = CV_RGB(0,0,250);

// Text variables
const char* text = “testing”;
double hscale = 1.0;
double vscale = 0.8;
double shear = 0.2;
int thickness2 = 1;
int line_type = 8;

IplImage* src1 = cvLoadImage(“C:\\prado.jpg”,1);
CvFont font1;

cvRectangle( src1, cvPoint(270,30), cvPoint(300,150),cvScalar(0,250,0) );
cvShowImage(“Drawing_and_Text”, src1);

return 0;

How to Capture frame(pictures) from a video or CAM?

Here in this OpenCV tutorial i will show you, that how to get frame from your web came and then show it in your open cv window.

First of all you should understand here, that i am not going to call a web cam and make a video, but here in this tutorial i will capture the picture from a user or any object through CAM and will use this pic in my own created Open CV window, and it will look like a video is going on.Actually it is not a video from a CAM, but it is the combination of all the pictures which i have capture throug my CAM and have put it into my Open CV window.

You can get picture either from CAM or from any video which is placed in your computer. here in this tutorial i’ll get all the frame from a CAM.

int main()
CvCapture* capture = 0;
capture = cvCaptureFromCAM(0);
// capture =cvCaptureFromAVI(“C:\\Users/Public/Videos/Sample Videos/wildlife.wmv”);//if we want to use our  video,

printf(“Could not initialize capturing…\n”);
return -1;
IplImage* frame = 0;

frame = cvQueryFrame(capture);
cvShowImage(“video”, frame);

//press ‘escape’ key to terminate the program
int c = cvWaitKey(20);
if((char)c==27 )//27 is ASCII value of ‘escape’ key
return 0;

return 0;