ข้อดีของ opencv และ จะเขียนได้อย่างไร

Posted by Undermine on 18:55 comments (0)

ข้อดีของ Opencv

1. เป็น library ที่นำไปใช้ได้เลยครับ algorithm พวกพื้นฐานไม่ต้องมาคิดหรือโค้ดเอง ฟรีด้วยครับ
2. มี source code และ ตัวอย่างให้มาด้วย สามารถนำโค้ดที่มี ใน opencv ไปประยุกต์ใชได้
3. มี yahoo group เป็นที่รวมตัวของคนที่ใช้จากทั่วโลก
4. opencv ถูกพัฒนาจากทีม พัฒนาของ intel และ optimize code สำหรับ cpu 586 ของ intel
คิดว่า น่าจะ รุ่นที่มีพวก คำสั่งพิเศษขึ้นมานะครับ เช่น พวก mmx sse ทำให้เป็น library ที่มีความเร็วในการประมวล
ผลอยู่ในระดับต้นๆ เร็วกว่า ที่มีขายบางตัวด้วยครับ

คำถามยอด ฮิต จะใช้ opencv ดีไหม

Posted by Undermine on 18:52 comments (0)

Q จะเริ่มเล่น Image Processing ใช้ opencv ดีไหมครับ


A คือคำว่า “เล่น image Processing” นี่หมายความกว้างแค่ไหนเหรอครับ

ถ้าจะแค่ลองเปลี่ยนภาพสีเป็น gray scale หรือ จับก้อนสีที่เราสนใจ (connected component)อะไรแบบนี้ ก็ไม่จำเป็นต้องยึดติดกับ openCV หรอกครับ ภาษาทั่วๆไป อย่าง Java เองก็มี library ที่ช่วยในการจัดการกับไฟล์รูปภาพอยู่แล้ว เช่น แปลงไฟล์รูปภาพให้เป็น array ของค่า RGB ของแต่ละ pixel ซึ่งก็น่าจะสะดวกกว่า openCV นะครับ เพราะรู้สึกว่า openCV มันจะต้องใช้กับ C++ มั้ง ถ้าจำไม่ผิด ซึ่ง C++ นี่ก็เป็นภาษาที่ค่อนข้างน่าเหนื่อยใจพอสมควร
แต่ถ้าจะทำอะไรที่มันพิสดารกว่าเปลี่ยนรูปสีเป็น gray scale เช่น การแก้ไขความเบี้ยวของภาพที่เกิดจาก lens distortion อะไรงี้ ก็คงต้องใช้ openCV ล่ะครับ เพราะ openCV มี method สำเร็จรูปไว้จัดการกับเรื่องแบบนี้อยู่แล้ว ส่วน library ของ ภาษาอื่น ผมไม่แน่ใจว่ามันจะมี method เจ๋งๆเหมือน openCV รึเปล่า
สรุปก็คือ ถ้าจะทำอะไรที่ไม่พิสดารมาก ก็ไม่จำเป็นต้องใช้ openCV เพราะมันต้องเขียน C++ ซึ่งเปลืองพลังงานอย่างแรง ภาษาอื่นก็มี library ให้ใช้ แต่ถ้าจะทำอะไรหรูหรา ก็คงต้อง openCV

Creating an OpenCV application with Eclipse on Windows

Posted by Undermine on 18:45 comments (0)


เนื่องจากว่าผมใช้ระบบ Windows เป็นหลัก แต่งานวิจัยผมพัฒนาบน Ubuntu ซึ่งยังยอมรับว่าไม่สามารถใช้ Ubuntu เพียวๆ ได้ เป็นเหตุทำให้งานวิจัยค่อนข้างล่าช้าไปพอสมควร ผมจึงคิดว่าจะมาเขียนโปรแกรมบน Windows แทน และวันนี้ได้ลองผิดลองถูกที่จะใช้ OpenCV กับ Eclipse อยู่นานมาก ขอจดขั้นตอนเก็บไว้หน่อยละกัน
โปรแกรมที่จำเป็นต้องติดตั้ง
  1. MinGW: เป็นชุดคำสั่งรวมพวกไลบรารี่ของภาษา Programming ซึ่งในที่นี้โปรแกรมที่จะติดตั้งก็คือ C/C++ compiler
  2. Eclipse CDT: ดั้งเดิมเป็น IDE สำหรับภาษา Java แต่ตัวนี้ได้ติดตั้งโปรแกรมเสริมให้รองรับการพัฒนาภาษา C/C++
  3. OpenCV for Windows: และแน่นอนที่ขาดไม่ได้ นั่นก็คือ OpenCV ซึ่งเป็นชุดคำสั่งรวมพวกไลบรารี่ของการพัฒนาโปรแกรมทาง Computer Vision หรือ Image Processing

การจัดการปัญหา Memory Leak ใน OpenCV (C/C++)

Posted by Undermine on 18:42 comments (2)


ความรู้ใหม่ได้มาจากเว็บของ Andol ผมนำบางส่วนมาแปลเป็นไทยมาลงไว้กันลืม และเผื่อจะเป็นประโยชน์ต่อหลายๆ คนครับ โดยงานผมจะเกี่ยวข้องการกับวิเคราะห์รูปภาพดังนั้นส่วนที่เอามาคือ เฉพาะส่วน Memory leak ของการประกาศตัวแปร IplImage
ถ้าโค้ดของเรามีดังนี้

OpenCV on Linux again with G++

Posted by Undermine on 17:36 comments (0)


After a long way try to develop C program with OpenCV library on Ubuntu Linux using NetBeans and Eclispe IDE, no succeed at all. There are always some problems occurs and the project cannot move on further so everything has to be move back onto Windows to be developed. But now all these thing can be developed in Linux by  using traditional GNU C Compiler (GCC) that most of Linux users know it very well. This is the complete procedure from the beginning(install) till the end(compile-build).
Part A. Install OpenCV 2.0.0
1. Install prerequisites
Enter this line into Linux Terminal:

Installing OpenCV from the cvs version for Ubuntu 5

Posted by Undermine on 17:33 comments (0)


First, there are a few dependencies to sort out. You will need to install the following packages - using Synaptic.

  • cvs - so you can get the files
    • If you don't use cvs normally, type touch ~/.cvpass to create an empty password file (or else you'll get error messages)
  • gcc - so you can compile them
  • g++ - "
  • libgtk2.0-dev
  • Various image libraries - libimlib2 and libimlib2-dev get most of them. OpenCV requires libpng, libjpeg and libtiff with the -dev versions so check they are there too...

Installing OpenCV for Ubuntu 6.06 (Dapper) UPDATED

Posted by Undermine on 17:31 comments (0)


You might want to use this distribution because it has longer support, some packages seem to be more stable than later ones and for me at least it runs faster than 7.04!
Note that there is an older section (struck out), which I have kept as we recently had a case where it was necessary to install the older version of ffmpeg!
  1. Install subversion and all the basic compilation packages such as g++ and gcc etc.
  2. Download ffmpeg with: svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg and then
    • ./configure --enable-shared --prefix=/opt/ffmpeg (the prefix bit is optional but I prefer to store special development packages like this one on their own directory so it is simpler to locate, configure, remove)

Installing OpenCV for Ubuntu 7.04 (Feisty)

Posted by Undermine on 17:30 comments (0)


You might want to use this distribution because it has corrected bugs from previous ones, supports your hardware better, etc.
Thanks to Leeds University for their guide on using OpenCV
  1. Install subversion and all the basic compilation packages such as g++ and gcc etc.
  2. Download ffmpeg with: svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg and then
    • ./configure --enable-shared --prefix=/opt/ffmpeg (the prefix bit is optional but I prefer to store special development packages like this one on their own directory so it is simpler to locate, configure, remove)
    • make
    • sudo make install

Installing OpenCV for Ubuntu 8.04

Posted by Undermine on 17:29 comments (0)


We have tried the officially supported version of this, i.e. runnning KDE 3.x instead of 4.x
Note that installation on version 7.10 follows the same procedure, but I never got round documenting it
Things seem to be getting easier!
Thanks to Leeds University for their guide on using OpenCV
  1. sudo apt-get install build-essential to get compiler, ld, make, ....
  2. Install the other necessary packages: sudo apt-get install libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev
  3. Now download and untar version 1.0.0 of OpenCV from http://sourceforge.net/project/showfiles.php?group_id=22870&package_id=16948
  4. Now do

เริ่มต้นกับ OpenCV บน linux

Posted by Undermine on 17:23 comments (0)


OpenCV เป็นไลบรารี่ภาษา C ตัวหนึ่ง  ที่ถูกสร้างขึ้นมาเพื่องาน Image Processing โดยที่สามารถทำงานร่วมกับ IDE ทั่วไป และสามารถทำงานได้บนทุกแพลตฟอร์ม ไม่ว่าจะเป็นวินโดว์ ลินุกซ์ หรือ MacOS
สิ่งที่มันทำได้ (โดยคร่าวๆ)
- ทำงาน Image Processing ได้เกือบทุกประเภท ไม่ว่าจะลด noise / edge detection / hough transform / Feature Detection (ถ้าให้อธิบายแบบชาวบ้านก็คือ ทำทุกอย่างที่ Photoshop ทำได้)
- สามารถทำงานได้กับทั้งภาพนิ่ง วีดีโอ (ไฟล์ทุกสกุลที่ codec สามารถอ่านได้) และทำงานกับกล้องแบบ real-time ได้