Powered by Blogger.

Tuesday, December 18, 2012

Tag: , , ,

Mastering OpenCV with Practical Computer Vision Projects

Announcing the new "Mastering OpenCV" book that I co-authored!

The book "Mastering OpenCV with Practical Computer Vision Projects" is now for sale from Packt Publishing with free shipping to many countries! Each chapter is a separate project containing step-by-step tutorials + full source-code using the latest C++ interface of OpenCV v2.4, written by 7 authors that are well-known among the OpenCV community for their blogs & open-source projects.

Chapters (each is a project with full source-code):
- Cartoonifier and Skin Changer for Android.
- Marker-based Augmented Reality on iPhone or iPad.
- Marker-less Augmented Reality.
- Exploring Structure from Motion using OpenCV.
- Number Plate Recognition using SVM and Neural Networks.
- Non-rigid Face Tracking.
- 3D Head Pose Estimation using AAM and POSIT.
- Face Recognition using Eigenfaces or Fisherfaces.
- Developing Fluid Wall using the Microsoft Kinect.

Authors (in alphabetical order):
- Daniel Lélis Baggio ("http://code.google.com/p/ehci/")
- Shervin Emami ("http://www.shervinemami.info/openCV.html")
- David Millán Escrivá ("http://blog.damiles.com/")
- Khvedchenia Ievgen ("http://computer-vision-talks.com/")
- Naureen Mahmood ("http://howdweknows.blogspot.com/")
- Jason Saragih ("http://jsaragih.org/")
- Roy Shilkrot ("http://www.morethantechnical.com/")

The book can be purchased from "http://www.packtpub.com/cool-projects-with-opencv/book" either as a physical book or as a PDF eBook.

The latest code can be downloaded from "https://github.com/MasteringOpenCV/code", including a screenshot of each project (scroll down on the front page).

Note: You should already have basic experience with OpenCV and C/C++ before reading this book, as this book does not explain the basics of OpenCV and it assumes you already have it installed. For example, you could read the "Learning OpenCV" book and/or the "OpenCV 2 Cookbook" to learn the basics of OpenCV, then read this "Mastering OpenCV" book for more advanced skills and project ideas!Mastering OpenCV with practical computer vision projects

About David Millán Escrivá

David completed his studies in Universidad Politecnica de Valencia in IT with a Master's degree in artificial intelligence, computer graphics, and pattern recognition, focusing on pattern recognition and Computer Vision. David has more than 15 years of experience in IT, with more than ten years of experience in Computer Vision, computer graphics, and pattern recognition, working on different projects and start-ups, applying his knowledge of Computer Vision, optical character recognition, and augmented reality. Co-Author of two OpenCV books and reviewer of few more.

59 comments:

  1. [...] http://blog.damiles.com/2012/12/mastering-opencv-with-practical-computer-vision-projects/) 分类: 新闻 标签: 评论 (0) Trackbacks (0) 发表评论 [...]

    ReplyDelete
  2. [...] (From: http://blog.damiles.com/2012/12/mastering-opencv-with-practical-computer-vision-projects/) [...]

    ReplyDelete
  3. David, went thru your tutorial in the book, and the question I have is what's the reason to select the 144x33 size for the training data? how to you establish that size? Can the data / training data be size independent?

    ReplyDelete
  4. I bought this book because I´m always using examples from internet and your blog it´s one of my favorite places for learning about opencv. I hope there will be new posts and book about opencv.

    ReplyDelete
  5. Hi, the training data must be the same size. In the book sample i use all the image pixels as training data, then all images must have the same size, and i check diferent sizes for get good results and this is one that we get good results.

    If you want get image size independent, you must get other training data, for example PCA, LDA, ... But this data must have the same size for the training data.

    ReplyDelete
  6. Hi, about traininng OCR file, I think for me will be better a new OCR .xml file, because my country uses a different kind of true type font. So I need to create my traing files with 5 x 5, 10 x 10, 15 x 15, and 20 x 20 and select the best for me or use all? And in trainOCR.cpp what is numFilesChars?

    ReplyDelete
  7. Hi Ricardo, You must use the best for you, 5x5 or 10x10 or another.

    In trainOCR the numFilesChars, is the number of files that you store to train in path/CHAR/X.jpg where X is from 1 to numfilesChars[CHAR]

    ReplyDelete
  8. hi,
    1>DetectRegions.obj : error LNK2001: unresolved external symbol "public: virtual class cv::GlBuffer __thiscall cv::_InputArray::getGlBuffer(void)const " (?getGlBuffer@_InputArray@cv@@UBE?AVGlBuffer@2@XZ)
    1>DetectRegions.obj : error LNK2001: unresolved external symbol "public: virtual class cv::GlTexture __thiscall cv::_InputArray::getGlTexture(void)const " (?getGlTexture@_InputArray@cv@@UBE?AVGlTexture@2@XZ)
    1>DetectRegions.obj : error LNK2001: unresolved external symbol "public: virtual class cv::gpu::GpuMat __thiscall cv::_InputArray::getGpuMat(void)const " (?getGpuMat@_InputArray@cv@@UBE?AVGpuMat@gpu@2@XZ)

    what can be this error in ANPR?
    I use openCV 2.3 and Visual Studio 2008 and I don't have a GPU.
    I think youcan give me a quick reply.
    thankz

    ReplyDelete
  9. Hi,
    I training my OCR.xml file with 25x25 chars and included TrainingDataF25, I included A,E,I,O,U because my country has this caracteres. I see the OCR.cpp use TrainingDataF15, I didn't change this yet.

    But in OCR.cpp at
    ann.predict(f, output)
    show me this error:
    OpenCV Error: Incorrect size of input array (input matrix must have the same number of columns as the number of neurons in the input layer) in predict.

    I don´t know what is wrong, if I change my OCR.xml for the original file, the program runs Ok, but give me a wrong OCR result.

    ReplyDelete
  10. Yes you have to change the line 366 Mat f=features(ch,15); to 25 that are the features that you are using. If not the train and the predict use diferent number of features.

    ReplyDelete
  11. It's very strange error because i don't use any GPU code in the tutorial.

    ReplyDelete
  12. @damiles :thankz for your reply,it was a problem with dlls.It is ok now.
    BTW i need to train the OCR database for new characters.Can u please explain it from the scratch ? I don't understand this "TrainingDataF15" thing at all.

    1.How to save the training characters?
    2.How to make class labels?
    thank you,
    hasith

    ReplyDelete
  13. I bought the ebook recently. But I can not find chapter 9. I can download the codes, but the link to chapter 9 is broken.
    Where can I get the extra chapter?

    ReplyDelete
  14. Hi Damiles , i tried to run the ANPR project on beagle board XM with ubuntu 12.04 , its running with out any error , but its showing wrong out put , but the same library works well on Laptop with Ubuntu 12.10 can you tell me what will be the reason ..?

    ReplyDelete
  15. Hi Dalmies I executed Your Pgm trainOCR.cpp with my own Data But i am getting Error on its Line Number 320 :(
    else{
    trainClasses.at(i,k) = 0;
    }
    It is not displaying Any Error When i am executing it without "else" part. Y is it so??

    ReplyDelete
  16. Hi,
    I'm trying to see how ANPR works. I wanted to know how to specify the image file in ANPR.soln. When I run the program, it doesn't ask me to input the image file.

    ReplyDelete
  17. So, I finally understood that I must pass image location as argument while executing the program. But now I'm encountering another error:

    C:\ANPR\Debug>ANPR.exe C:\test1.JPG
    OpenCV Automatic Number Plate Recognition
    working with file: test1
    OpenCV Error: Bad argument (train data must be floating-point matrix) in cvCheck
    TrainData, file ..\..\..\src\opencv\modules\ml\src\inner_functions.cpp, line 857

    Please help me to resolve this problem.

    ReplyDelete
  18. So, I finally understood that I must pass image location as argument while executing the program. But now I'm encountering another error:

    C:\ANPR\Debug>ANPR.exe C:\test1.JPG
    OpenCV Automatic Number Plate Recognition
    working with file: test1
    OpenCV Error: Bad argument (train data must be floating-point matrix) in cvCheck
    TrainData, file ..\..\..\src\opencv\modules\ml\src\inner_functions.cpp, line 857

    Please help me to resolve this problem.

    ReplyDelete
  19. Hi Sir, Could you please explain us about the train part of OCR.xml .

    1)trainOCR.cpp file
    2)where to save new character set in project folder ?
    3)How to give access to the folder which contains characters for training ?!

    Help would be appreciated greatly.
    Thank you!!
    tushara.

    ReplyDelete
  20. I have runtime OpenCV error in DetectRegions.cpp in line:
    int area = floodFill(input, mask, seed, Scalar(255,0,0), &ccomp, Scalar(loDiff, loDiff, loDiff), Scalar(upDiff, upDiff, upDiff), flags);

    OpenCV Error: Unsupported format or combination of formats () in cvFloodFill, file /Users/alexandershishkov/opencv2.4.3rc/opencv/modules/imgproc/src/floodfill.cpp, line 621

    Any ideas?

    Should say I find very unusual assignment to local flags variable several lines above:

    int flags = connectivity + (newMaskVal << 8 ) + CV_FLOODFILL_FIXED_RANGE + CV_FLOODFILL_MASK_ONLY;

    Really should be plus but not bitwise or?

    ReplyDelete
  21. OCR.cpp, line 37.
    Use parameter trainFile, not string literal!

    ReplyDelete
  22. OCR.cpp.
    Please, never ever use DEBUG as variable or ivar. It's popular macro name!

    ReplyDelete
  23. Can you send me an image of your output? Sorry to reply to late.

    ReplyDelete
  24. Sorry to reply to late, i will make a tutorial in few days with how to train ocr.

    ReplyDelete
  25. i will make a tutorial in few days with how to train ocr.

    ReplyDelete
  26. Yes you have reason, i will rename it and upload code.
    i will make a tutorial in few days with how to train ocr.

    ReplyDelete
  27. Damiles, pay attention to compiler warnings.
    Unused variables and unused variable results in code pretending be tutorial is not very good.

    ReplyDelete
  28. Damiles, I think I now understand how your approach to number plate detection and recognition works. We all read such books not only to borrow code but to be taught how to build such applications. Unfortunately you don't explain in details how MLP used in ANPR was trained and evaluated. As for me it's the most important part of ANPR application.

    ReplyDelete
  29. I don't like algorithm depends too much on how points for floodFill are chosen. That's most unreliable part of number plate detection. Sometimes plate is detected from second or third attempt on same still image. Should be another approach which will give more reliable results.

    ReplyDelete
  30. string Plate::str(){
    string result="";
    //Order numbers
    vector orderIndex;
    vector xpositions;
    for(int i=0; i< charsPos.size(); i++){
    orderIndex.push_back(i);
    xpositions.push_back(charsPos[i].x);
    }
    float min=xpositions[0];


    Damiles, there are circumstances when xpositions is empty by the time and last line crashes app. Unsafe code.

    ReplyDelete
  31. You can certainly see your enthusiasm in the work you write.
    The world hopes for even more passionate writers such as you
    who aren't afraid to say how they believe. At all times go after your heart.

    ReplyDelete
  32. I have a same problem as Aijin's. Program works well in my laptop but does not work properly with my evaluation board(i.MX53 Quick Start Board). Can you help me to understand what will be the reason ? For instance we evaluate the program for 2515DTZ but we have 1F1612 as a result. But we have correct result for determining the licence plate location, problem is in the ANN part.

    ReplyDelete
  33. Hi,
    I am working with AAM and POSIT chapter 7. This book provides a source for creating AAM model but not search and fitting. Any help with search and fitting code.
    Please need help.
    thanks

    ReplyDelete
  34. same error
    OpenCV Error: Bad argument (train data must be floating-point matrix) in cvCheck
    TrainData, file ..\..\..\src\opencv\modules\ml\src\inner_functions.cpp, line 857
    Please help me to resolve this problem.

    ReplyDelete
  35. Hi,damiles

    what‘s the use of data
    const int numFilesChars[]={35, 40, 42, 41, 42, 33, 30, 31, 49, 44, 30, 24, 21, 20, 34, 9, 10, 3, 11, 3, 15, 4, 9, 12, 10, 21, 18, 8, 15, 7};
    Is the name of some files about corresponding character?

    when it comes to ann,the train phase is always done before using phase,how to save the weight data and use ann to classify in the second round?

    thank you.

    ReplyDelete
  36. This is the number of files for each character for train purposes

    ReplyDelete
  37. would you offer method of OCR training?

    in the ANPR project,the input data of ann are downsampled,why?

    ReplyDelete
  38. Yes, i'm trying to finish a tutorial to explain how to train, but i don't have a lot of time to do it.

    Yes the input data are downsample because i test and check diferent sizes as input in the ANPR and this downsample size get better results.

    ReplyDelete
  39. I am trying to run the project after generating and building using CMake but the problem is that the code is not running in visual c++ 2008 the error is To register a module, you must provide a binary name
    any help!!

    ReplyDelete
  40. Hi,
    why have different result for same image? Some times the plates isn't recognized or is recognized but i have different value.

    ReplyDelete
  41. the palate locating method in the ANPR project is sensitive to the size and position of palate ,how to improve and implement the Haar feature face detection size and position invariance?
    would you please give some advice about that?
    thank you.

    ReplyDelete
  42. Hi David,

    How can I get the accuracy on ann.predict(f,output); ?

    Thanks.

    ReplyDelete
  43. I'm encountering a running error as someone else:
    C:\Users\QIN>F:\dip\code-master\Chapter5_NumberPlateRecognition\Debug\ANPR F:\di
    p\code-master\Chapter5_NumberPlateRecognition\test\2715DTZ.jpg
    OpenCV Automatic Number Plate Recognition
    working with file: 2715DTZ
    OpenCV Error: Bad argument (train data must be floating-point matrix) in cvCheck
    TrainData, file ..\..\..\src\opencv\modules\ml\src\inner_functions.cpp, line 857

    ReplyDelete
  44. Hello,

    Is there already made a tutorial for the trainOCR.exe?
    I've now build succesful the program for license plate recognition and i want to create my own OCR.xml file.
    Unfortunately i got an error message in a asembly file with:

    Unhandled exception at 0x1027d540 (msvcr100d.dll) in trainOCR.exe: 0xC0000005: Access violation reading location 0x00000000.

    Could u give me some advice or a tutorial about train the OCR?
    Thank you!

    ReplyDelete
  45. hello sir,

    is there any book related to JavaCV !

    ReplyDelete
  46. Hi all,
    I used ANPR algorithm. I ported this code on iOS App.
    I'm new about OpenCV.
    When I use some example photos the code works well and recognizes license plates.
    Now I tried to take the pictures taken with the camera of the iPhone but I have always the same error (crash):
    The error is the same of Valeriy Van has reported in these comments

    int area = floodFill(input, mask, seed, Scalar(255,0,0), &ccomp, Scalar(loDiff, loDiff, loDiff), Scalar(upDiff, upDiff, upDiff), flags);
    OpenCV Error: Unsupported format or combination of formats () in cvFloodFill, file /Users/alexandershishkov/opencv2.4.3rc/opencv/modules/imgproc/src/floodfill.cpp, line 621

    some suggestions?

    ReplyDelete
  47. Can anybody prepare a video to show how ANPR code works? I could not run the codes and I do not know where the error is. So please help me or contact me.


    kerim.topcu@windowslive.com

    ReplyDelete
  48. I'm trying to port an android app for number plate recognition from your tutorial and i found github source for the same https://github.com/MasteringOpenCV/.I much impressed the way you explained the process. I need you suggestion to make cmake build compilation on android JNI. Let me know anyother way to port app for android

    ReplyDelete
  49. I followed the code by Damiles, works well, thanks, Damiles!
    If someone still needs to know, how to train OCR and use pretrained yml resource, I can explain it here in brief. Of course, if Damiles doesn't mind ^^)

    ReplyDelete
  50. Est-il possible de copier deux trois phrases sur mon site web ?

    ReplyDelete
  51. In fact, alll the reasons mentioned above are applicable to all men and
    women. There must be hundreds of weigut loss plans and programs out there that
    promise weight loss for little or no effort. Start a food
    journal and write down every meal and snack to consume in a 24-hour period.


    Have a look at my homepage - prodotto green coffee

    ReplyDelete
  52. wonderful points altogether, you simply won a logo new reader.
    What may you recommend in regards to your put up that you made some days ago?
    Any sure?

    ReplyDelete
  53. I don't even know how I finished up here, however I assumed this submit was
    once good. I do not realize who you are but certainly you are going to a famous blogger when you aren't
    already. Cheers!

    ReplyDelete
  54. Great post. I used to be checking constantly this
    weblog and I'm inspired! Very helpful info specially the ultimate
    part :) I take care of such information a lot. I was looking
    for this certain info for a long time. Thanks and best of luck.

    ReplyDelete
  55. I think the admin of this website is really working hard in favor of his website, because here every stuff is quality based information.

    ReplyDelete
  56. Hi damiles,
    I am reading the book, It is very nice!

    In Chapter 4 : Exploring Structure from Motion using OpenCV

    Assuming my camera is fixed, my target object is moving by rotating and moving

    I have a question want to ask:

    u = Vx / Vz * f;
    v = Vy / Vz * f;
    As a View Port projection transformation;

    Point = (u, v, w) '
    Matrix_c =
    (f 0 0 0
    0 f 0 0
    0 0 1 0)
    Matrix_m = (....) //// 4 x 4 matrix;
    Object_v = (x, y, z, 1) ' ; ///// a vector in my target object

    and
    V = ( Vx, Vy, Vz, Vw ) ' ;


    so
    V = Matrix_m * Object_v;
    u' = Vx * f;
    v' = Vy * f;
    w' = Vz;

    but the real value is ( u v 1 );



    How to understand the w' != 1 ??


    My English is poor , But I hope you would understand.



    thank you.

    : )

    ReplyDelete
  57. I found the answer to my question


    thank you

    ReplyDelete
  58. Dear.
    Please, how can I improve the accuracy of the algorithm of OCR?

    Do I have to improve the SVM?
    

    ReplyDelete
  59. OCR.cpp changed codes:
    const char OCR::strCharacters[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8',
    '9', 'A', 'B', 'V', 'G', 'D', 'Z', 'I', 'K', 'L', 'M', 'N', 'O',
    'Q', 'R', 'S', 'T', 'U', 'Y', 'H', 'F', 'E', 'W', 'P' };
    const int OCR::numCharacters=33;

    trainOCR.cpp changed codes:
    const int numFilesChars[]={ 15, 42, 28, 29, 34, 20, 19, 16, 23, 21, 19,
    19, 17, 17, 49, 19, 17, 25, 23, 20, 39, 18, 20, 20, 21, 19, 36, 21,
    40, 19, 16, 15, 13 };

    then on terminal ./trainOCR chars/
    it works perfectly. But when i run ANPR, i get this error
    OpenCV Automatic Number Plate Recognition
    working with file: 8995CCN
    Num plates detected: 1
    OpenCV Error: Incorrect size of input array (input matrix must have the same number of columns as the number of neurons in the input layer) in predict, file /home/droid/OpenCV/opencv-2.4.9/modules/ml/src/ann_mlp.cpp, line 283
    terminate called after throwing an instance of 'cv::Exception'
    what(): /home/droid/OpenCV/opencv-2.4.9/modules/ml/src/ann_mlp.cpp:283: error: (-201) input matrix must have the same number of columns as the number of neurons in the input layer in function predict
    Do you know what is causing a problem?

    ReplyDelete