jump to navigation

Configuring Dev-Cpp for compiling C programs using the OpenCV May 8, 2012

Posted by viboon in : C , add a comment

Before configuring the Dev-Cpp, we need:
- Dev-Cpp
- MinGW
- CMake
- OpenCV

1. Download and extract or install Dev-Cpp, MinGW, CMake and OpenCV; also add C:\Dev-Cpp\bin\;C:\MinGW\bin\ into the system path.

2. Use CMake to build OpenCV binaries from the source code.

In CMake, fill in the source code and the binary generated directories.

Where is the source code: C:/OpenCVSource
Where to build the binaries: C:/OpenCV

Click “Configure” and select “MinGW Makefiles” as the generator.

Select “Specify native compilers”.

The C and C++ compilers are specified as follows:

C: C:/MinGW/bin/gcc.exe
C++: C:/MinGW/bin/g++.exe

Click “Finish”.

In the configuration screen type in “RELEASE” (or “DEBUG” if you want to build a debug version) for “CMAKE_BUILD_TYPE”.

Click “Configure” and “Generate”, respectively.

Go to the command prompt and inside the directory “C:\OpenCV” type:

mingw32-make

and

mingw32-make install

3. Configure the Dev-Cpp so it knows where to find OpenCV for your projects.

Go to “Tools -> Compiler Options”

Click “+” sign to add a new compiler named here, OpenCV.

On the section “Add these commands to the linker command line”
-lopencv_core231 -lopencv_highgui231 -lopencv_imgproc231 -lopencv_features2d231 -lopencv_calib3d231

In “Directories” tap, add the following into “Binaries”, “Libraries”, “C Includes” and “C++ Includes”.
*** Binaries ***
C:\mingw\bin
C:\OpenCV\bin
*** Libraries ***
C:\mingw\lib
C:\OpenCV\lib
*** C Includes ***
C:\mingw\include
C:\OpenCV\include
*** C++ Includes ***
C:\mingw\include
C:\OpenCV\include

Ref:
- http://opencv.willowgarage.com/wiki/InstallGuide
- http://opencv.willowgarage.com/wiki/MinGW
- http://opencv.willowgarage.com/wiki/DevCpp


Tags: , , , , ,

Related posts:

การใช้ dictionary ใน Python July 23, 2011

Posted by viboon in : Python , add a comment
>>> x={'a':'ant', 'c':'cat', 'b':'bat', '1':'10'}
>>> x['c']
'cat'
>>> x['1']
'10'

การ copy ข้อมูลจาก x ไปที่ y

>>> y=x.copy()

การตรวจสอบข้อมูลใน dictionary

>>> y.has_key('b')
True
>>> y.has_key('d')
False

ลบข้อมูลใน dictionary

>>> x.clear()
>>> x
{}

Tags: , ,

Related posts:

String ใน Python (2) July 23, 2011

Posted by viboon in : Python , add a comment

การแทนตัวแปรใน string

>>> string1="var 1 is %s, and var 2 is %s"
>>> var=('text1', 'text2')
>>> print string1 % var
var 1 is text1, and var 2 is text2

การหาตำแหน่งของคำใน string

>>> x="Hello everybody"
>>> x.find('everybody')
6

การใช้ method join

>>> x=['ant','cat','rat']
>>> y='bat'
>>> y.join(x)
antbatcatbatratbat

เปลี่ยน string ให้เป็น lowercase

>>> x="HeLlo woRLd"
>>> x.lower()
'hello world'

การแทนที่ด้วย method replace

>>> x="hello work"
>>> x.replace('work', 'holiday')
'hello holiday'

Tags: , , , , , , ,

Related posts:

Sort ใน Python July 23, 2011

Posted by viboon in : Python , add a comment
>>> x=[7,4,2,2,3]
>>> x.sort()
>>> x
[2, 2, 3, 4, 7]
 
>>> sorted('eXtreme')
['X', 'e', 'e', 'e', 'm', 'r', 't']

ถ้าเป็นข้อมูลแบบ tuples จะเปลี่ยนแปลงไม่ได้

>>> x=(7,4,2,2,3)
>>> x
(7,4,2,2,3)

Tags: ,

Related posts:

Real Time Microphone and Camera Data Acquisition in Matlab July 18, 2011

Posted by viboon in : Matlab , add a comment

Developed by Theodoros Giannakopoulos

Ref: http://www.mathworks.com/matlabcentral/fileexchange/18596-real-time-microphone-and-camera-data-acquisition-and-audio-video-processing


Tags: , , , ,

Related posts:

Video Sudoku Solver by Matlab July 18, 2011

Posted by viboon in : Matlab , add a comment

This program was developed by Teja Muppirala.

Solves a sudoku with a web camera and then displays it while tracking the original video feed. The Image Acquisition and Image Processing Toolboxes are required.

To get the Matlab files: http://www.mathworks.com/matlabcentral/fileexchange/30088-video-sudoku-solver


Tags: , , ,

Related posts:

Crop image by using Matlab July 18, 2011

Posted by viboon in : Matlab , add a comment

Cropping ‘ngc6543a.jpg’ image when Xmin=230, Ymin=230, width=200, height=200, so that the crop rectangular vector is [230,230,200,200], respectively.

1
2
I = imread('ngc6543a.jpg');
c = imcrop(I,[230,230,200,200]);

Original image

Cropped image


Tags: , ,

Related posts:

การคำนวณการปริมาตรใต้พื้นผิวด้วย Trapezoidal numerical integration June 28, 2011

Posted by viboon in : Mathematics, Matlab , add a comment

Trapezoidal numerical integration เป็นการหา Integral ของ function ด้วยการประมาณพื้นที่ใต้กราฟ(หรือพื้นผิว)เป็นส่วนย่อยๆ ที่มีรูปร่างเป็นพื้นที่แบบสี่เหลี่ยมคางหมู (Trapezoid)

ในตัวอย่างนี้กำหนดให้หาปริมาตรใต้ surface function

Z = X^2 \sin \left[ {5\left( {X - Y} \right)} \right]

โดยการหา double integral ผ่านวิธี Trapezoidal method

1
2
3
4
5
6
7
xdata = [0; rand(100,1); 1];
ydata = [0; rand(100,1); 1];
x = sort(xdata);
y = sort(ydata);
[X,Y] = meshgrid(x,y);
Z = X.^2.*sin(5*(X-Y));
trapz(y,trapz(x,Z,2),1)

ในกรณีนี้จะได้คำตอบ

ans =
    0.0497

เมื่อใช้วิธี double integral แบบทั่วไป

1
2
F = @(x,y)(x.^2).*sin(5*(x-y));
dblquad(F,0,1,0,1)

คำตอบคือ

ans =
    0.0498

Tags: , , , , , ,

Related posts: