Showing posts with label Image Processing Tutorial. Show all posts
Showing posts with label Image Processing Tutorial. Show all posts

Saturday, August 15, 2009

To run you must install .Net Framework: v2.0

When you have developed a .NET application and then you want to run the executable file, you may get the following error:
"To run you must install .Net Framework: v2.0.50727 ..."

Simply, just download the Microsoft .NET Framework and install on your PC. Some cases, restart the PC is required.

Cheers..

Sunday, July 27, 2008

Load & Display Image using OpenCV

Let's start to create our first project!

1. Open OpenCV workspace: Click Start-->All Programs-->OpenCV-->OpenCV Workspace MSVC6
2. Create new C++ source file: Click File-->New-->C++ Source File. Put the file name & the folder. Now you have a blank editor to write the code.
3. Write the following code:

#include "cv.h" //main OpenCV header
#include "highgui.h" //GUI header

int main() {
// declare a new IplImage pointer

IplImage* myimage;


// load an image

myimage = cvLoadImage("sayyidsmile.jpg",1); //change the file name with your own image

//create a new window & display the image

cvNamedWindow("Smile", 1);

cvMoveWindow("Smile", 100, 100);

cvShowImage("Smile", myimage);


//wait for key to close the window

cvWaitKey(0);

cvDestroyWindow( "Smile" );

cvReleaseImage( &myimage );

return 0;


}

4. Add library in the project setting: Click Project-->Setting-->Link-->Object/Library Modules then write cv.lib cvaux.lib cxcore.lib highgui.lib. Make sure that you do this step anytime you create a new project.
5. Save and click "Execute Program" icon, then your window named "Smile" will appear.

Easy right ...? Explore other functions in OpenCV and enjoy it !

Saturday, July 26, 2008

cxcore100.dll or highgui100.dll not found error

Several days ago, my friend ask me about DLL file linking error. This is the problem:

PROBLEM: When I run my project, OpenCV gave an error like this:
"This application has failed to start because cxcore100.dll was
not found. Re-installing the application may fix this problem
"

SOLUTION: Add OpenCV DLL (...OpenCV/bin) directory to system PATH.
For detail of how to add to the system PATH, please refer to my previous posting: How to setup OpenCV ?

The same solution is also solved the error caused by missing others DLL files, such as highgui100.dll not found.

Some friends suggested to copy cxcore100.dll to the directory of the .exe file. But ofcourse it's tedious since we should copy every time we create a project.

Good luck! If you still got problems, please write in comment area.

Thursday, July 24, 2008

How to setup OpenCV ?

As I mentioned before, OpenCV is an open source library of computer vision in C/C++. Before you can use it, of course you must have Visual C/C++ or Visual.Net installed in your PC. Me, I'm using Visual C++ 6.0 for my project.

The following are the procedures to setup OpenCV:

  1. Download the OpenCV installation file from here. Find the latest version.
  2. Run (double click) the installation file. After completed, you will get OPENCV icon menu in your PROGRAM.
  3. Make a linking in the system PATH to OpenCV DLLs files, using the below steps:
  • Click My Computer --> Properties --> Advanced --> Environment Variables --> Systems variable --> highlight PATH --> Edit.
  • Add "C:\Program Files\OpenCV\bin" to PATH. The location of OpenCV DLL files might be differentEach different path file is separated by semicolon (;)
  • If your OpenCV is already opened, you should close it then open again to take effect of the new path.
4. Customize the GLOBAL OPTIONS- In your OpenCV window, click Tools --> Options and select Directories tab
  • Select directories for Include files, then add four OpenCV directories as show in the figure.
  • Also add OpenCV directories for Library & Search files (see the figure)


Now your OpenCV is ready for creating your own project. How to develop a project using OpenCV? Be patient for the next tutorial.

If you have problems or suggestion related to this article, please feel free to give comments. TQ.

Monday, July 21, 2008

OpenCV: An Easy Way of Computer Vision Programming

OpenCV is an open source of computer vision library which is developed by INTEL in the C/C++ platform. It is a very powerful library which provides various library for many application in computer vision system, such as matrix manipulation, basic image processing, structural analysis, motion analysis, object recognition & real time interfacing.

Web resources:
Official webpage: http://www.intel.com/technology/computing/opencv/
Software download: http://sourceforge.net/projects/opencvlibrary/
Others will be listed later.

Friday, July 18, 2008

Interfacing with Parallel Port using MATLAB

Some applications in MATLAB environment need to communicate with external device either to send or receive signals. MATLAB provides a simple way to handle this task with PC parallel port.



Parallel port IDs and pin number:

Port ID

Pins

Description

0

2 – 9

Eight I/O lines, MSB = pin 9

1

10 – 13 and 15

Five input lines used for status (output pins)

2

1, 14, 16 and 17

Five I/O lines used for control (input pins)

MATLAB has digital I/O (DIO) subsystems which are designed to transfer digital values to and from hardware. To send out data, follow the below procedures:

  1. To check the support of your system, type

daq=daqhwinfo(‘parallel’)

  1. Create a Digital I/O Object with the digitalio function

dio=digitalio(‘parallel’,’lpt1’);

  1. Add lines to a Digital I/O Object

addline(dio,0:7,0,'out'); % add the hardware lines 0 until 7 from port 0 to the

% digital object dio

  1. Send data to the lines

putvalue(dio.line(1),1); % send data ‘1’ to line 1

Before executing the program, of course you must have the parallel connection attached to your PC and some LED to indicate that the digital data have been sent.

Have a nice practice controlling your device via parallel port, and please give your comments!

Wednesday, July 16, 2008

Video & Image Acquisition using MATLAB

This article is a part of module I had prepare for the Shortcourse on "Machine Vision Application for Oil Palm Grading", at the Faculty of Electrical & Electronics Engineering, Universiti Malaysia Pahang, Kuantan-Pahang. I was appointed by my colleague, Mas Kamarul, as invited instructor for the topic Real Time Interfacing using MATLAB.

In the machine vision system, data acquisition is the first step which programmer should aware. You want to preview object using your camera, capture it, store the captured image in your PC? With simple way, you will get your own preview window of your webcam by following this tutorial.

Equipments:

  1. CCD camera & frame grabber or webcame
  2. PC with MATLAB 7.x
Procedures:
  1. Make sure that you have a functional CCD camera or webcam connected to your PC. Functional means it's driver has been installed in your PC. To see whether your camera can work well or not, you can install a windows standard video capture, named AMCAP.
  2. MATLAB has built-in adaptor to communicate with the acquisition device. To check whether your MATLAB has this support or not, type

>> cam=imaqhwinfo

cam =

InstalledAdaptors: {1x1 cell}
MATLABVersion: [1x12 char]
ToolboxName: [1x25 char]
ToolboxVersion: [1x12 char]

>> cam.InstalledAdaptors

ans =

'winvideo'

For more information about your device, type

>> device_info=imaqhwinfo('winvideo',1)

  1. Type the following code in your editor and run the program

vid=videoinput(‘winvideo’);

preview(vid)


  1. To capture the video, type

im=getsnapshot(vid)

imshow(im)

Check your workspace, now you have RGB image data im.

  1. To store the image data to a .jpg or .gif file, type


imwrite(im,’myimet.jpg’);


Very easy? If you face any problem or you have suggestions, do not hesitate to write in the comments area below.