RSS

Category Archives: C++

Install OpenCV 2.4.3 on Visual Studio 2010

 
Leave a comment

Posted by on January 30, 2013 in C++

 

Tags:

Capture Video With OpenCV

#include "stdafx.h"
#include<opencv\cv.h>
#include<opencv\cxcore.h>
#include<opencv\highgui.h>

using namespace cv;
int _tmain(int argc, _TCHAR* argv[])
{

 CvCapture *capture = cvCaptureFromCAM(0);
 if( !capture ) return 1;
 cvNamedWindow("Video");

while(true) {

 IplImage* frame = cvQueryFrame( capture );
 if( !frame ) break;
 cvShowImage( "Video", frame );
 int c = cvWaitKey(40);
 if((char)c==20 ) break;
 }

cvDestroyWindow("Video");
 cvReleaseCapture( &capture );
 return 0;
}

&nbsp;

 
Leave a comment

Posted by on January 29, 2013 in C++

 

Tags:

Passing command line parameters

 #include <iostream>
 using namespace std;
 int main( int argc, char **argv )

{

//for taking command line arguments
bool numFound=false;
char myCharArray[10];
int x=argc;
int y;
cout <<"You entered  "<<x-1  <<" parameters after the command \"commandLine.\""<<endl;
cout <<"They were:  ";
for (int i=1; i<x; i++)
{
strcpy(myCharArray, argv[i]);
cout <<myCharArray<<"  ";
}

cout<<endl;
for (int i=1; i<x; i++)
{
strcpy(myCharArray, argv[i]);
if(isdigit(myCharArray[0]))
{

if(numFound==false)
cout<<"The number(s) you entered were:  ";

numFound=true;
y=atoi(argv[i]);
cout <<y<<" ";

}

}

cout <<endl;

}


 
 
Leave a comment

Posted by on November 25, 2011 in C++

 

Determine prime numbers


#include <iostream>

using namespace std;
int main()
{
int num=0;
int count=0;
int prime=1;
char ans=' ';
do
{
cout <<"Enter a number:  ";
cin >> num;
for (int i=(num)/2; i>1; i--)
{
if (num%i==0)
{
count=count+1;
if (count==1)
cout <<"Internal Factor(s):  ";
prime=0;
cout <<i<<" ";
}
}
if (prime==0)
{
cout<<"\nNumber is not prime."<<endl;
}
if (prime==1)
{
cout <<"Number is prime."<<endl;
}
cout<<"Do you wish to find another prime:  ";
cin>>ans;
cin.ignore(200,'\n');
count=0;
prime=1;
system("cls");
}while(ans =='y' || ans=='Y');
system("pause");
return 0;
}

 
Leave a comment

Posted by on November 25, 2011 in C++