Thursday, January 8, 2009

Interfacing Parallel Port Using Visual C++

I've been searching around a lot to find some straight forward solution to deal with parallel port using Visual C, but after around a week of searching and wasting time got the solution still in a quite indirect way...so thought of writing it here...
Tools Required for Interfacing Parallel Port in Visual C++
1. Microsoft Visual Studio
2. inpout32.dll (www.logix4u.net)
3. inpout32.lib (www.logix4u.net)

Step and Code for Parallel Port Interfacing.
1. Creat a new Visual C++ Project using Visual Studio
2. Copy the inpout32.dll and inpout32.lib into your project directory
3. Goto project properties (Alt+F7), Expand Configuration Properties, Expand Linker, Click on Input, and type inpout32.lib in Additional Dependencies row and click Ok
4. Open the C source file of the project and code
#include "stdafx.h"
#include "stdio.h"
#include "conio.h"
#include "string.h"
#include "stdlib.h"
/* ----Prototypes of Inp and Outp--- */

short _stdcall Inp32(short PortAddress);
void _stdcall Out32(short PortAddress, short data);

/*--------------------------------*/

void main(void)
{
int Data; //Data to be sent on parallel port
Out32(0X378,Data); //if Inp32(0x378); used then it will take input from parallel port

}

now to check the working of the program execute LPT.exe it will start monitoring your prarallel power status, and you may check the code you just compiled.

Best of Luck

Thursday, January 1, 2009

OpenCV Image Processing - Template Matching

Matching an external file with video optained

//Standard Header
#include "stdafx.h"
//OpenCV header
#include "cv.h"
#include "highgui.h"

//Start of main function
int main( int argc, char** argv )
{
//Enable camera input
CvCapture* capture = cvCreateCameraCapture(0);
//Terminate Program if camera feed is not available
assert( capture != NULL );
//Create Window named Output
cvNamedWindow( "Output", CV_WINDOW_AUTOSIZE );

//Pointers for tracker
double m,M;
IplImage* image; IplImage* icon;
CvPoint point1;
CvPoint point2;

//continuous loop to obtain frames from the cam and display at output window
while(1)
{
//Bring each frame to image variable
image = cvQueryFrame( capture );
//If no input then terminate
if( !image )
break;
//Tracking Procedures
//Load tracking image
icon=cvLoadImage("a.jpg",1);
int resultW = image->width - icon->width + 1;
int resultH = image->height - icon->height +1;
IplImage* result = cvCreateImage(cvSize(resultW, resultH), IPL_DEPTH_32F, 1);
cvMatchTemplate(image, icon, result, CV_TM_SQDIFF);
cvMinMaxLoc(result, &m, &M, &point2, &point1, NULL);
cvRectangle( image, point2, cvPoint( point2.x + icon->width, point2.y + icon->height ), cvScalar( 0, 0, 255, 0 ), 1, 0, 0 );

cvShowImage( "Output", image );
//Delay to wait before returning to the loop to get next frame
char c = cvWaitKey(33);
//If escape ket pressed then terminate
if( c == 27 )
break;
}
//During program end release camera so it could be used by another application
cvReleaseCapture( &capture );
//Close the Output Window created earlier
cvDestroyWindow( "Output" );
}

OpenCV Image Processing - Video Acquisition

To Capture Video using a Webcam

//Standard Header
#include "stdafx.h"
//OpenCV header
#include "cv.h"
#include "highgui.h"

//Start of main function
int main( int argc, char** argv )
{
//Enable camera input
CvCapture* capture = cvCreateCameraCapture(0);
//Terminate Program if camera feed is not available
assert( capture != NULL );
//Create Window named Output
cvNamedWindow( "Output", CV_WINDOW_AUTOSIZE );
//Frames pointer
IplImage* image;

//continuous loop to obtain frames from the cam and display at output window
while(1)
{
//Bring each frame to image variable
image = cvQueryFrame( capture );
//If no input then terminate
if( !image )
break;

cvShowImage( "Output", image );
//Delay to wait before returning to the loop to get next frame
char c = cvWaitKey(33);
//If escape ket pressed then terminate
if( c == 27 )
break;
}
//During program end release camera so it could be used by another application
cvReleaseCapture( &capture );
//Close the Output Window created earlier
cvDestroyWindow( "Output" );
}

Wednesday, September 24, 2008

Setting Up A Web Server

Its quite easy, since long time i've been thinking about how to host my site at the lowest possible cost (free ofcourse)...well i did host my site on difference free webhosts but all of them had some disadvantage, some didn't had much bandwidth, some didn't had the adons i required, and most of them placed their ads on my site ruining my web layout :(...so finally i decided to host my site on my own computer...
to do so just follow below and remember its all done free of cost
Register a FREE domain at dyndns.com
Download their free client application and install it in your startup so that if your ip address changes it gets updated automatically
Then register another FREE domain at http://www.co.cc/
Then signin to you co.cc account and redirect it to your dyndns domain name
Thats all for the the domain setup...now for the computer setup...
Definitely to run your website you need to have webserver installed...
For Windows IIS is there (which i'm using)
For Linux Apache is there
well there are many other webservers like miniwebserver, tinyweb, wwwserver etc
Just check the webservers site to see which suits you, but my recommendation would be go with the operating systems own server...
well after deciding and installing the webserver just copy and paste you website files into the webservers recommended folder...and walla...your sites up...
now who ever will login to your site will be visiting the site placed at your pc... (remember your computer needs to be 24 hours on in order to make your site available to visiters)

after completing this whole process the path which your users will follow to access your site would be something like...

CO.CC Domain >>> DYNDNS Domain >>> Your IP Address >>> Site Files at Your PC
for example
http://jamshiddastur.co.cc/ >>> http://jamshid.is-a-geek.co.uk/ >>> 58.xxx.xxx.xxx >>> index.htm

Best of Luck in setting your own server

Tuesday, September 23, 2008

Why Tech Technology?

I'm a fan of technology, for the time being am testing things so would post details later :)
for the time being you may visit http://jamshiddastur.co.cc to know more about me...