<configuration>
<appSettings>
<add key="ConnStr" value="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\MyData\App_Data\Database.mdf;Integrated Security=True;User Instance=True"/>
</appSettings>
<connectionStrings>
<add name="ConnStr" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\MyData\App_Data\Database.mdf;Integrated Security=True;User Instance=True"/>
</connectionStrings>
</configuration>
The Fingerprint in LINUX
Monday, June 3, 2013
App setting
Sunday, June 2, 2013
Aspx for a 3 tire validation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace test
{
public partial class Student : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
hdnSTDID.Value = "Add";
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
string stdName = tbxName.Text;
DBConnection dbConnection = new DBConnection();
if (hdnMode.Value == "Add")
{
string sql = "INSERT INTO Student ([Name]) VALUES ('" + stdName + "')";
dbConnection.ExecuteQuary(sql);
string script = "alert(\"ADDfgfh..!\");";
ScriptManager.RegisterStartupScript(this, this.GetType(),
"ServerControlScript", script, true);
}
if (hdnMode.Value == "Edit")
{
int stdId = int.Parse(hdnSTDID.Value);
string sqlEdite = "UPDATE Student SET Name = '" + stdName + "' WHERE StdId=" + stdId;
dbConnection.ExecuteQuary(sqlEdite);
hdnMode.Value = "Add";
btnSave.Text = "Add";
}
gvStudent.DataBind();
tbxName.Text = "";
}
protected void gvStudent_RowCommand(object sender, GridViewCommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument);
string studentId = gvStudent.Rows[index].Cells[0].Text;
int stdID = int.Parse(studentId);
DBConnection con = new DBConnection();
if (e.CommandName == "Del")
{
string strDelete = "DELETE FROM Student WHERE StdId=" + stdID;
con.ExecuteQuary(strDelete);
gvStudent.DataBind();
}
if (e.CommandName == "Edi")
{
string sqlEdite = "SELECT StdId, Name FROM Student WHERE StdId=" + stdID;
DataSet ds = con.GetData(sqlEdite);
hdnSTDID.Value = ds.Tables[0].Rows[0]["StdId"].ToString();
tbxName.Text = ds.Tables[0].Rows[0]["Name"].ToString();
btnSave.Text = "Edite";
hdnMode.Value = "Edit";
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace test
{
public partial class Student : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
hdnSTDID.Value = "Add";
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
string stdName = tbxName.Text;
DBConnection dbConnection = new DBConnection();
if (hdnMode.Value == "Add")
{
string sql = "INSERT INTO Student ([Name]) VALUES ('" + stdName + "')";
dbConnection.ExecuteQuary(sql);
string script = "alert(\"ADDfgfh..!\");";
ScriptManager.RegisterStartupScript(this, this.GetType(),
"ServerControlScript", script, true);
}
if (hdnMode.Value == "Edit")
{
int stdId = int.Parse(hdnSTDID.Value);
string sqlEdite = "UPDATE Student SET Name = '" + stdName + "' WHERE StdId=" + stdId;
dbConnection.ExecuteQuary(sqlEdite);
hdnMode.Value = "Add";
btnSave.Text = "Add";
}
gvStudent.DataBind();
tbxName.Text = "";
}
protected void gvStudent_RowCommand(object sender, GridViewCommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument);
string studentId = gvStudent.Rows[index].Cells[0].Text;
int stdID = int.Parse(studentId);
DBConnection con = new DBConnection();
if (e.CommandName == "Del")
{
string strDelete = "DELETE FROM Student WHERE StdId=" + stdID;
con.ExecuteQuary(strDelete);
gvStudent.DataBind();
}
if (e.CommandName == "Edi")
{
string sqlEdite = "SELECT StdId, Name FROM Student WHERE StdId=" + stdID;
DataSet ds = con.GetData(sqlEdite);
hdnSTDID.Value = ds.Tables[0].Rows[0]["StdId"].ToString();
tbxName.Text = ds.Tables[0].Rows[0]["Name"].ToString();
btnSave.Text = "Edite";
hdnMode.Value = "Edit";
}
}
}
}
Wb.Cnfg
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<!--<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>-->
<add name="connectionStringa" connectionString="data source=LOCHANA-PC;initial catalog=StdMngSystem;user id=;password=;multipleactiveresultsets=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/"/>
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"/>
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<!--<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>-->
<add name="connectionStringa" connectionString="data source=LOCHANA-PC;initial catalog=StdMngSystem;user id=;password=;multipleactiveresultsets=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/"/>
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"/>
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
DBC
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Data;
/// <summary>
/// Summary description for DBConnection
/// </summary>
///
namespace StdMngSystem
{
public class DBConnection
{
SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionStringa"].ToString());
SqlCommand command = null;
SqlDataAdapter adapter = null;
public void ExecuteQuary(string quary)
{
try
{
if (connection.State == ConnectionState.Closed)
{
connection.Open();
command = new SqlCommand();
}
command.CommandText = quary;
command.Connection = connection;
command.ExecuteNonQuery();
connection.Close();
}
catch (Exception)
{
}
}
public DataSet GetData(string quary)
{
if (connection.State == ConnectionState.Closed)
{
connection.Open();
adapter = new SqlDataAdapter(quary, connection);
}
DataSet getDataSet = new DataSet();
adapter.Fill(getDataSet);
connection.Close();
return getDataSet;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Data;
/// <summary>
/// Summary description for DBConnection
/// </summary>
///
namespace StdMngSystem
{
public class DBConnection
{
SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionStringa"].ToString());
SqlCommand command = null;
SqlDataAdapter adapter = null;
public void ExecuteQuary(string quary)
{
try
{
if (connection.State == ConnectionState.Closed)
{
connection.Open();
command = new SqlCommand();
}
command.CommandText = quary;
command.Connection = connection;
command.ExecuteNonQuery();
connection.Close();
}
catch (Exception)
{
}
}
public DataSet GetData(string quary)
{
if (connection.State == ConnectionState.Closed)
{
connection.Open();
adapter = new SqlDataAdapter(quary, connection);
}
DataSet getDataSet = new DataSet();
adapter.Fill(getDataSet);
connection.Close();
return getDataSet;
}
}
}
Wednesday, January 9, 2013
Read from a File Line by line JAVA
File:-
network devices.txt
10.30.12.106
10.30.11.155
10.60.100.97
192.168.50.197
10.60.100.96
10.10.5.75
10.10.5.100
10.10.5.76
192.168.1.1
10.10.5.68
code:-
try {
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("networkdevices.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
int num = 0;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
//System.out.println (strLine);
//System.out.println ("a");
switch (num) {
case 0:
a = strLine;
break;
case 1:
b = strLine;
break;
case 2:
c = strLine;
break;
case 3:
d = strLine;
break;
case 4:
e = strLine;
break;
case 5:
f = strLine;
break;
case 6:
g = strLine;
break;
case 7:
h = strLine;
break;
case 8:
i = strLine;
break;
case 9:
k = strLine;
break;
default:
break;
}
num++;
}
//Close the input stream
in.close();
} catch (Exception e) {//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
note:- a,b,c,d...h are strings . should be initialize globally
:)
cheers
Thursday, December 13, 2012
Small Open CV project
Netbeans...........
Create project C++ application
******************************************************1**** In main add ...**********************************************************************
/*
* File: main.cpp
* Author: lochana
*
* Created on 13 December, 2012, 11:16 AM
*/
#include <stdio.h>
#include <string.h>
#include <string.h>
#include<iostream>
#include <pthread.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include "ImageProcess.hpp"
using namespace std;
ImageProcess* p_ImageProcess;
void * StartGuiRef(void * p)
{
/////////////////SERIAL PORT INIT///////////////////////////////////////////////
///////////////////SERIAL PORT INIT/////////////////////////////////////////////
p_ImageProcess=new ImageProcess;
cout<<"...........Object Created.........\n";
IplImage *frame;
IplImage *CombinedImage;
int brightness=196;
//CvCapture* capture = cvCreateCameraCapture(0) ;
CvCapture* capture = cvCaptureFromCAM(0) ;
cvNamedWindow("Ilakke");
cvCreateTrackbar("Brightness", "Ilakke", &brightness, 255, NULL);
cout<<"...........Cammara Initialized.........\n";
p_ImageProcess->SerialPortInit();
while(1){
p_ImageProcess->InitializeGraph();
while(1){
p_ImageProcess->SerialPortStatus();
frame = cvQueryFrame( capture );
p_ImageProcess->SetMainCaptureFrame(frame);
p_ImageProcess->Do_AllProcess();
p_ImageProcess->SetBrigtness(brightness);
//p_ImageProcess->DrawTheGraph();
cvWaitKey(2);
cvShowImage("Ilakke",p_ImageProcess->GetShowImage());
if(p_ImageProcess->GetGraphPosition()==1200){ break;}
}
//p_ImageProcess->RefreshGraph();
cvWaitKey(5);
cout<<"............thread gui.......\n";
}
}
int main(int argc, char**argv) {
pthread_t pt_GuiTread;
int i_ptGui = pthread_create(&pt_GuiTread,NULL,StartGuiRef,NULL);
while(1){//cout<<"............thread main.......\n";
}
return 0;
}
**************************************************************2*****ImageProcess.cpp*****************************************************
/*
* File: ImageProcess.cpp
* Author: lochana
*
* Created on 13 December, 2012, 11:19 AM
*/
#include "ImageProcess.hpp"
ImageProcess::ImageProcess() {
NumOfShot=0;
NumOfRealShot=0;
}
ImageProcess::ImageProcess(const ImageProcess& orig) {
}
ImageProcess::~ImageProcess() {
}
void ImageProcess::SetMainCaptureFrame(IplImage* frame){
CaptureFrame=frame;
}
void ImageProcess::Do_GrayScale(){
GrayScaleFrame=cvCreateImage(cvGetSize(CaptureFrame),IPL_DEPTH_8U,1);
cvCvtColor(CaptureFrame,GrayScaleFrame,CV_RGB2GRAY);
}
IplImage* ImageProcess::GetShowImage(){
return ImageToShow;
}
void ImageProcess::Do_AllProcess(){
Do_GrayScale();
Do_FindFirePoint();
Do_DrawAllShot();
ImageCenter.x=(int)(0.5*CaptureFrame->width);
ImageCenter.y=(int)(0.5*CaptureFrame->height);
Do_DrawCircles();
cvShowManyImages(CaptureFrame,CaptureFrame,ImageGraph);
}
void ImageProcess::Do_FindFirePoint(){
double minVal, maxVal;
CvPoint minLoc, maxLoc;
cvMinMaxLoc(GrayScaleFrame, &minVal, &maxVal, &minLoc, &maxLoc, 0);
if(maxVal>i_Brigtness){
FirePoint=maxLoc;
if(bRealFire){
RealFirePoint[NumOfRealShot]=FirePoint;
NumOfRealShot++;
}else{
AllFirePoint[NumOfShot]=FirePoint;
NumOfShot++;
}
if(NumOfShot==998){std::cout<<".............988...shot....\n";}
}
}
void ImageProcess::Do_DrawAllShot(){
for( int k= 0; k <NumOfShot; k++ ){
cvCircle(CaptureFrame,AllFirePoint[k],5,CV_RGB(255,255,0),-1);
}
for( int k= 0; k <NumOfRealShot; k++ ){
cvCircle(CaptureFrame,RealFirePoint[k],5,CV_RGB(255,0,0),-1);
}
}
void ImageProcess::Do_DrawCircles(){
cvCircle(CaptureFrame,ImageCenter,10,CV_RGB(0,255,0),-1);
cvCircle(CaptureFrame,ImageCenter,30,CV_RGB(0,255,0),0);
cvCircle(CaptureFrame,ImageCenter,70,CV_RGB(0,255,0),0);
cvCircle(CaptureFrame,ImageCenter,100,CV_RGB(0,255,0),0);
cvCircle(CaptureFrame,ImageCenter,130,CV_RGB(0,255,0),0);
cvCircle(CaptureFrame,ImageCenter,160,CV_RGB(0,255,0),0);
cvCircle(CaptureFrame,ImageCenter,190,CV_RGB(0,255,0),0);
cvCircle(CaptureFrame,ImageCenter,220,CV_RGB(0,255,0),0);
cvCircle(CaptureFrame,ImageCenter,250,CV_RGB(0,255,0),0);
}
void ImageProcess::SetBrigtness(int btr){
i_Brigtness=btr;
}
void ImageProcess::InitializeGraph(){
x=10;i_gp=0;j_gp=10;
yx=yy=yz=valx=valy=valz=nvalx=nvaly=nvalz=i_GraphPosition=0;
ImageGraph=cvCreateImage(cvSize(1200,500), IPL_DEPTH_8U, 3);//a very long window
cvLine(ImageGraph,cvPoint(10, 250),cvPoint(2000, 250),cvScalar(0, 255, 0, 0), 1, 8, 0);//y-ax
cvLine(ImageGraph,cvPoint(10, 0),cvPoint(10, 500),cvScalar(0, 255, 0, 0), 1, 8, 0);//x-ax
valx=valy=valz=250;
}
void ImageProcess::RefreshGraph(){
cvReleaseImage(&ImageGraph);
}
void ImageProcess::DrawTheGraph(){
nvalx=100*(sin(0.05*i_gp));//-CentX);//your input
nvaly=100*(sin(0.05*i_gp+10));//-CentY);//10*data.d_GyroDatax;;
nvalz=100*sin(0.05*i_gp+20);
nvalx=(FirePoint.x-ImageCenter.x);//your input
nvaly=(FirePoint.y-ImageCenter.y);//10*data.d_GyroDatax;;
i_gp=i_gp++;
yx=250-nvalx;
yy=250-nvaly;
yz=250-nvalz;
cvLine(ImageGraph,cvPoint(j_gp,valx),cvPoint(x,yx),cvScalar(0,0, 255, 0), 1, 8, 0);
cvLine(ImageGraph,cvPoint(j_gp,valy),cvPoint(x,yy),cvScalar(0,255,255, 0), 1, 8, 0);
//cvLine(img,cvPoint(j_gp,valz),cvPoint(x,yz),cvScalar(0,255, 0, 0), 1, 8, 0);
j_gp=j_gp++;
x=j_gp;
valx=yx;
valy=yy;
valz=yz;
//cvShowImage("GRAPH", img);
//cvWaitKey(2);
i_GraphPosition=j_gp;
}
int ImageProcess::GetGraphPosition(){
return i_GraphPosition;
}
void ImageProcess::cvShowManyImages(IplImage *MainImage,IplImage *ImSub1,IplImage *ImSub2) {
IplImage *DispImage;
// Create a new 3 channel image
DispImage = cvCreateImage( cvSize(1000,600), 8, 3 );
// Set the image ROI to display the current image
cvSetImageROI(DispImage, cvRect(200, 20,MainImage->width,MainImage->height));
// Resize the input image and copy the it to the Single Big Image
cvResize(MainImage, DispImage);
cvResetImageROI(DispImage);
// Set the image ROI to display the current image
cvSetImageROI(DispImage, cvRect(20,20,30,MainImage->height));
// Resize the input image and copy the it to the Single Big Image
cvResize(ImSub1, DispImage);
// Reset the ROI in order to display the next image
cvResetImageROI(DispImage);
// Set the image ROI to display the current image
cvSetImageROI(DispImage, cvRect(200,20+MainImage->height,0.1*(ImSub2->width),0.1*(ImSub2->height)));
// Resize the input image and copy the it to the Single Big Image
cvResize(ImSub2, DispImage);
// Reset the ROI in order to display the next image
cvResetImageROI(DispImage);
ImageToShow= DispImage;
ImageToShow=CaptureFrame;
}
void ImageProcess::SerialPortInit(){
fd=0;
bRealFire=false;
fd = open("/dev/ttyUSB3", O_RDWR | O_NOCTTY);
struct termios options;
/*
* Get the current options for the port...
*/
tcgetattr(fd, &options);
cfsetispeed(&options, B9600);
cfsetospeed(&options, B9600);
/*
* Enable the receiver and set local mode...
*/
options.c_cflag |= (CLOCAL | CREAD);
/*
* Set the new options for the port...
*/
tcsetattr(fd, TCSANOW, &options);
}
void ImageProcess::SerialPortStatus(){
cout<<".........."<<fd<<"....\n";
//if(fd!=8){
int rd=
read(fd,psResponse,1);
//if(rd<0){return;}
printf("Bytes sent are %d \n",rd);
cout<<"....."<<psResponse<<"\n";
if(*psResponse=='A'){cout<<"..................$$$\n";
bRealFire=false;
}
else{
cout<<"..........................................@@@\n";
bRealFire=true;
}
// }
//* */
//return b_fired;
}
**************************************************************************8***3*****ImageProcess.hpp******************************************************
/*
* File: ImageProcess.h
* Author: lochana
*
* Created on 13 December, 2012, 11:19 AM
*/
#ifndef IMAGEPROCESS_HPP
#define IMAGEPROCESS_HPP
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <unistd.h>
#include <math.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <iostream>
using namespace std;
class ImageProcess {
public:
ImageProcess();
ImageProcess(const ImageProcess& orig);
virtual ~ImageProcess();
void SetMainCaptureFrame(IplImage* frame);
IplImage* CaptureFrame;
IplImage* GrayScaleFrame;
IplImage* GetShowImage();
void Do_AllProcess();
void SetBrigtness(int btr);
void InitializeGraph();
void RefreshGraph();
IplImage* ImageGraph;
void DrawTheGraph();
int GetGraphPosition();
void cvShowManyImages(IplImage *MainImage,IplImage *ImSub1,IplImage *ImSub2);
IplImage* ImageToShow;
void SerialPortInit();
void SerialPortStatus();
private:
void Do_GrayScale();
void Do_FindFirePoint();
void Do_DrawAllShot();
CvPoint FirePoint;
CvPoint AllFirePoint[1000];
CvPoint RealFirePoint[1000];
int NumOfShot;
int NumOfRealShot;
CvPoint ImageCenter;
void Do_DrawCircles();
int i_Brigtness;
int yx,yy,yz,valx,valy,valz,x,nvalx,nvaly,nvalz,i_gp,j_gp,i_GraphPosition;
int fd,ir,ig,ib;
char psResponse[1];
bool bRealFire;
};
#endif /* IMAGEPROCESS_HPP */
********************************************************************
project properties
Linker-->Additional library directories
/user/local/include/opencv
/user/local/include/opencv2
Linker-->Library-->Add library
/user/local/lib *select all*
Linker-->Library--> standerd library--> *Posix threads*
Install Opencv 2.4.3 in Ubantu 10.10 or higher [10 steps]
1. Down Netbeans 6.9 using Ubuntu software center.
2. install netbeans-7.2.1-ml-cpp-linux.sh
3.//We are going to setup OpenCV to use the new Qt highgui interface, which is much better than the simple highgui interface. Also, we will install OpenCV with support for OpenGL, as well as reading and writing videos, access to a webcam, Python, C and C++ interfaces, and Intel Threading Building Blocks (TBB).
OK, so the first step is to make sure that everything in the system is updated and upgraded:
3.1 sudo apt-get update
sudo apt-get upgrade
//Now, you need to install many dependencies, such as support for reading and writing image files, drawing on the screen, some needed tools, etc… This step is very easy, you only need to write the following command in the Terminal:
3.2 sudo apt-get install build-essential libgtk2.0-dev libjpeg62-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install sphinx-common
//Time to get the OpenCV 2.4.3 source code:
3.3 cd ~
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.3/OpenCV-2.4.3.tar.bz2
tar -xvf OpenCV-2.4.3.tar.bz2
cd OpenCV-2.4.3

//Now we have to generate the Makefile by using cmake. In here we can define which parts of OpenCV we want to compile. Since we want to use Python, TBB, OpenGL, Qt, work with videos, etc, here is where we need to set that. Just execute the following line at the terminal to create the appropriate Makefile. Note that there are two dots at the end of the line, it is an argument for the cmake program and it means the parent directory (because we are inside the build directory, and we want to refer to the OpenCV directory, which is its parent).
cd build
cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..

////Check that the above command produces no error and that in particular it reports FFMPEG as YES. If this is not the case you will not be able to read or write videos. Also, check that Python, TBB, OpenGL, V4L, OpenGL and Qt are detected.
//Now, you are ready to compile and install OpenCV 2.x.x:
3.4 make
sudo make install
//Now you have to configure OpenCV. First, open the opencv.conf file with the following code:
3.5 sudo gedit /etc/ld.so.conf.d/opencv.conf
//Add the following line at the end of the file(it may be an empty file, that is ok) and then save it:
3.6 /usr/local/lib

//Run the following code to configure the library:
3.7 sudo ldconfig
//Now you have to open another file:
3.8 sudo gedit /etc/bash.bashrc
//Add these two lines at the end of the file and save it:
3.9 PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH

//Finally, close the console and open a new one, restart the computer or logout and then login again. OpenCV will not work correctly until you do this.
Now you have OpenCV 2.4.3 installed in your computer with Python, TBB, OpenGL, video, and Qt support.
******************************************************************************************************************************************
Test....................................................
Now let’s build some samples included in OpenCV:
1 cd ~/OpenCV-2.4.3/samples/c
2 chmod +x build_all.sh
3 ./build_all.sh
Now we are ready to run the examples:
1 ./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" --scale=1.5 lena.jpg
detect face
2 ./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_eye.xml" --scale=1.5 lena.jpg

set background black
3. ~/OpenCV-2.4.3/build/bin/grabcut ~/OpenCV-2.4.3/samples/cpp/lena.jpg
********************************************************************************************************************************************
Subscribe to:
Comments (Atom)