Giter VIP home page Giter VIP logo

code's Introduction

============================================================================== Mastering OpenCV with Practical Computer Vision Projects

Full source-code for the book.

Source-Code:    https://github.com/MasteringOpenCV/code
Book:           http://www.packtpub.com/cool-projects-with-opencv/book
Copyright:      Packt Publishing 2012.

To build & run the projects for the book:

  • Install OpenCV (versions between 2.4.2 to 2.4.11 are supported, whereas OpenCV 3.0 is not yet supported). eg: go to "http://opencv.org/", click on Downloads, download the latest OpenCV 2.4 version (including prebuilt library), and extract it to "C:\OpenCV" for Windows or "/OpenCV" for Linux. In OpenCV v2.4.3, the prebuilt OpenCV library is in "C:\OpenCV\build" or "/OpenCV/build", such as "C:\OpenCV\build\x64\vc9" for MS Visual Studio 2008 (or "vs10" folder for MS Visual Studio 2010, or the "x86" parent folder for 32-bit Windows).

  • Install all the source code of the book. eg: extract the code to "C:\MasteringOpenCV" for Windows or "~/MasteringOpenCV" for Linux.

  • Install CMake v2.8 or later from "http://www.cmake.org/".

Each chapter of the book is for a separate project. Therefore there are 9 projects for the 9 chapters (remember that Chapter 9 is an online chapter that can be downloaded from "http://www.packtpub.com/cool-projects-with-opencv/book"). You can run each project separately, they each contain a README.md text file describing how to build that project, using CMake in most cases, because CMake can be used with many compilers and many operating systems.


Chapters:

  • Ch1) Cartoonifier and Skin Changer for Android, by Shervin Emami.
  • Ch2) Marker-based Augmented Reality on iPhone or iPad, by Khvedchenia Ievgen.
  • Ch3) Marker-less Augmented Reality, by Khvedchenia Ievgen.
  • Ch4) Exploring Structure from Motion using OpenCV, by Roy Shilkrot.
  • Ch5) Number Plate Recognition using SVM and Neural Networks, by David Escrivá.
  • Ch6) Non-rigid Face Tracking, by Jason Saragih.
  • Ch7) 3D Head Pose Estimation using AAM and POSIT, by Daniel Lélis Baggio.
  • Ch8) Face Recognition using Eigenfaces or Fisherfaces, by Shervin Emami.
  • Ch9) Developing Fluid Wall using the Microsoft Kinect, by Naureen Mahmood.

What you need for this book:

You don't need to have special knowledge in computer vision to read this book, but you should have good C/C++ programming skills and basic experience with OpenCV before reading this book. Readers without experience in OpenCV may wish to read the book Learning OpenCV for an introduction to the OpenCV features, or read "OpenCV 2 Cookbook" for examples on how to use OpenCV with recommended C/C++ patterns, because "Mastering OpenCV with Practical Computer Vision Projects" will show you how to solve real problems, assuming you are already familiar with the basics of OpenCV and C/C++ development.

In addition to C/C++ and OpenCV experience, you will also need a computer, and an IDE of your choice (such as Visual Studio, XCode, Eclipse, or QtCreator, running on Windows, Mac or Linux). Some chapters have further requirements, particularly:

  • To develop the Android app, you will need an Android device, Android development tools, and basic Android development experience.
  • To develop the iOS app, you will need an iPhone, iPad, or iPod Touch device, iOS development tools (including an Apple computer, XCode IDE, and an Apple Developer Certificate), and basic iOS and Objective-C development experience.
  • Several desktop projects require a webcam connected to your computer. Any common USB webcam should suffice, but a webcam of at least 1 megapixel may be desirable.
  • CMake is used in most projects, including OpenCV itself, to build across operating systems and compilers. A basic understanding of build systems is required, and knowledge of cross-platform building is recommended.
  • An understanding of linear algebra is expected, such as basic vector and matrix operations and eigen decomposition.

Per-chapter Requirements:

  • Ch1: webcam (for desktop app), or Android development system (for Android app).
  • Ch2: iOS development system (to build an iOS app).
  • Ch3: OpenGL built into OpenCV.
  • Ch4: PCL (http://pointclouds.org/) and SSBA (http://www.inf.ethz.ch/personal/chzach/opensource.html).
  • Ch5: nothing.
  • Ch6: nothing, but requires training data for execution.
  • Ch7: nothing.
  • Ch8: webcam.
  • Ch9: Kinect depth sensor.

Screenshots:

  • Ch1) Cartoonifier and Skin Changer for Android: Ch1) Cartoonifier and Skin Changer for Android
  • Ch2) Marker-based Augmented Reality on iPhone or iPad: Ch2) Marker-based Augmented Reality on iPhone or iPad
  • Ch3) Marker-less Augmented Reality: Ch3) Marker-less Augmented Reality
  • Ch4) Exploring Structure from Motion using OpenCV: Ch4) Exploring Structure from Motion using OpenCV
  • Ch5) Number Plate Recognition using SVM and Neural Networks: Ch5) Number Plate Recognition using SVM and Neural Networks
  • Ch6) Non-rigid Face Tracking: Ch6) Non-rigid Face Tracking
  • Ch7) 3D Head Pose Estimation using AAM and POSIT: Ch7) 3D Head Pose Estimation using AAM and POSIT
  • Ch8) Face Recognition using Eigenfaces or Fisherfaces: Ch8) Face Recognition using Eigenfaces or Fisherfaces
  • Ch9) Developing Fluid Wall using the Microsoft Kinect: Ch9) Developing Fluid Wall using the Microsoft Kinect

code's People

Contributors

bloodaxe avatar royshil avatar shervinemami avatar ssteve avatar tilmanb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

code's Issues

Chapter 3:Multiple Object Detection And Tracking

Hi if I were to perform parallel object detection and tracking for multiple objects using Markerless AR in Chapter 3 how would I do it.( using openmp)
If I were to include vocabulary tree in it and use kd tree for matching the input frame from the video and the keyframes in vocabulary tree how would I do it.
Just an idea of the flow would be fine .
I just want to implement the code in Markerless AR

Markerless Example Issue

in the markerless sample, when you set enableRatioTest = true, the programs throws an exception. am on osx and opencv2.3.4

"OpenCV Error: Assertion failed (K == 1 && update == 0 && mask.empty()) in batchDistance, file /Users/premithk/Desktop/openCV/OpenCV-2.4.3/modules/core/src/stat.cpp, line 1830"

Chapter 2, marker-AR not rendering

Hello,

I'm having a bit of trouble running the second chapter, respectively I've printed the marker, but it's not rendering anything on top of it. Moreover, the framebuffer seems to be deallocating when I start the application.

Any idea what might be wrong?

Tested on iOS 8.3, iPhone 5S.

Eigenface from images

Excuse me. COuld i ask you a question?
I read your page: http://www.shervinemami.info/faceRecognition.html and i see the tutorial and code working in offline mode in Servo Magazine page show how to recognize faces from image. I built the code as instruction. The program did not report any errors. But when i run the program, the black window appeared and disappeared right after that and not show the window to type the command. I don't understand why. I had the necessary files. The output when i buit shows that "Could not find or open pdb file".
Could you show me how to fix this problem? And can i use your system face recognition in shervinemami.info in both online and offline mode ?
Thanks for reading and help. I have to make a survey on recognition instantly.

error C3861: 'isinf': identifier not found and error C3861: 'isnan': identifier not found

when i try to build the program for structure from motion in OpenCV i get the error
1>------ Build started: Project: Sfm, Configuration: Release Win32 ------
1>Compiling...
1>BundleAdjuster.cpp
1>C:\Users\Reeba\Downloads\Programs\SSBA-3.0\Math/v3d_mathutilities.h(433) : error C3861: 'isinf': identifier not found
1>C:\Users\Reeba\Downloads\Programs\SSBA-3.0\Math/v3d_mathutilities.h(433) : error C3861: 'isnan': identifier not found
1>Build log was saved at "file://c:\Users\Reeba\Documents\Visual Studio 2008\Projects\Sfm\Sfm\Release\BuildLog.htm"
1>Sfm - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

when i add the lines

ifndef isinf

define isinf(x) ((x)!=(x))

endif

ifndef isnan

define isnan(x) ((x)!=(x))

endif

to v3d_mathutilities.h i get a lot of link errors

1>------ Build started: Project: Sfm, Configuration: Release Win32 ------
1>Compiling...
1>BundleAdjuster.cpp
1>Linking...
1>BundleAdjuster.obj : error LNK2001: unresolved external symbol "public: void __thiscall V3D::SparseLevenbergOptimizer::minimize(void)" (?minimize@SparseLevenbergOptimizer@V3D@@QAEXXZ)
1>BundleAdjuster.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall V3D::MetricBundleOptimizerBase::updateParametersB(struct V3D::VectorArray const &)" (?updateParametersB@MetricBundleOptimizerBase@V3D@@UAEXABU?$VectorArray@N@2@@z)

I dont know what I have to do for such type of errors.
I have been stuck with this code for sometime. Please Help. Its urgent

Chapter 6 not working

When i create project with code of chapter 6.

  • If i run the main function in file "visualize_face_tracker.cpp", i had a error:
    OpenCV Error: Assertion failed (type == B.type() && (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2)) in gemm, file /home/thiepnq/Documents/AndroidWorking/OpenCV/opencv-2.4.8/modules/core/src/matmul.cpp, line 711
  • If i run the main function in file "visualize_face_detector.cpp", i had a error:
    OpenCV Error: Parsing error (video.ogv(0): Too long string or a last string w/o newline) in icvXMLSkipSpaces, file /home/thiepnq/Documents/AndroidWorking/OpenCV/opencv-2.4.8/modules/core/src/persistence.cpp, line 1838

Please help me.

Chapter 4 :Structure From Motion build error

Hello i have made the required changes in the code and now I am able to configure the code. I have few build error which i have no clue on how to solve as am a beginner

This post has NOT been accepted by the mailing list yet.
This post was updated on Mar 04, 2014; 1:04pm.
Hi I am trying to execute the code from https://github.com/MasteringOpenCV/code/tree/master/Chapter4_StructureFromMotion
I have built it using cmake but i get these error

1>------ Build started: Project: ZERO_CHECK, Configuration: Debug Win32 ------
1>Build started 3/4/2014 1:37:00 PM.
1>InitializeBuildStatus:
1> Creating "Win32\Debug\ZERO_CHECK\ZERO_CHECK.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>FinalizeBuildStatus:
1> Deleting file "Win32\Debug\ZERO_CHECK\ZERO_CHECK.unsuccessfulbuild".
1> Touching "Win32\Debug\ZERO_CHECK\ZERO_CHECK.lastbuildstate".
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:00.07
2>------ Build started: Project: ExploringSfMExec, Configuration: Debug Win32 ------
2>Build started 3/4/2014 1:37:00 PM.
2>InitializeBuildStatus:
2> Touching "ExploringSfMExec.dir\Debug\ExploringSfMExec.unsuccessfulbuild".
2>CustomBuild:
2> All outputs are up-to-date.
2>ClCompile:
2> All outputs are up-to-date.
2>ManifestResourceCompile:
2> All outputs are up-to-date.
2>LINK : fatal error LNK1104: cannot open file 'C:\Qt\4.8.0\lib\QtGuid4.lib'
2>
2>Build FAILED.
2>
2>Time Elapsed 00:00:00.18
3>------ Build started: Project: ALL_BUILD, Configuration: Debug Win32 ------
3>Build started 3/4/2014 1:37:00 PM.
3>InitializeBuildStatus:
3> Creating "Win32\Debug\ALL_BUILD\ALL_BUILD.unsuccessfulbuild" because "AlwaysCreate" was specified.
3>CustomBuild:
3> Build all projects
3>FinalizeBuildStatus:
3> Deleting file "Win32\Debug\ALL_BUILD\ALL_BUILD.unsuccessfulbuild".
3> Touching "Win32\Debug\ALL_BUILD\ALL_BUILD.lastbuildstate".
3>
3>Build succeeded.
3>
3>Time Elapsed 00:00:00.07
========== Build: 2 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
The code is
/*****************************************************************************

  • ExploringSfMWithOpenCV
    ******************************************************************************
  • by Roy Shilkrot, 5th Dec 2012
  • http://www.morethantechnical.com/
    ******************************************************************************
  • Ch4 of the book "Mastering OpenCV with Practical Computer Vision Projects"
  • Copyright Packt Publishing 2012.
  • http://www.packtpub.com/cool-projects-with-opencv/book
    *****************************************************************************/

include "Common.h"

include <opencv2/highgui/highgui.hpp>

include <opencv2/imgproc/imgproc.hpp>

include

ifdef WIN32

#define WIN32_LEAN_AND_MEAN 1 
#define NOMINMAX 1 
#include <windows.h>

endif

include <gl/GL.h>//#include <GL/gl.h>

include <gl/GLU.h>// #include <GL/glu.h>

ifndef WIN32

include <dirent.h>

endif

using namespace std;
using namespace cv;

std::vectorcv::DMatch FlipMatches(const std::vectorcv::DMatch& matches) {
std::vectorcv::DMatch flip;
for(int i=0;i<matches.size();i++) {
flip.push_back(matches[i]);
swap(flip.back().queryIdx,flip.back().trainIdx);
}
return flip;
}

std::vectorcv::Point3d CloudPointsToPoints(const std::vector cpts) {
std::vectorcv::Point3d out;
for (unsigned int i=0; i<cpts.size(); i++) {
out.push_back(cpts[i].pt);
}
return out;
}

void GetAlignedPointsFromMatch(const std::vectorcv::KeyPoint& imgpts1,
const std::vectorcv::KeyPoint& imgpts2,
const std::vectorcv::DMatch& matches,
std::vectorcv::KeyPoint& pt_set1,
std::vectorcv::KeyPoint& pt_set2)
{
for (unsigned int i=0; i<matches.size(); i++) {
// cout << "matches[i].queryIdx " << matches[i].queryIdx << " matches[i].trainIdx " << matches[i].trainIdx << endl;
assert(matches[i].queryIdx < imgpts1.size());
pt_set1.push_back(imgpts1[matches[i].queryIdx]);
assert(matches[i].trainIdx < imgpts2.size());
pt_set2.push_back(imgpts2[matches[i].trainIdx]);
}
}

void KeyPointsToPoints(const vector& kps, vector& ps) {
ps.clear();
for (unsigned int i=0; i<kps.size(); i++) ps.push_back(kps[i].pt);
}

void PointsToKeyPoints(const vector& ps, vector& kps) {
kps.clear();
for (unsigned int i=0; i<ps.size(); i++) kps.push_back(KeyPoint(ps[i],1.0f));
}

define intrpmnmx(val,min,max) (max==min ? 0.0 : ((val)-min)/(max-min))

void drawArrows(Mat& frame, const vector& prevPts, const vector& nextPts, const vector& status, const vector& verror, const Scalar& _line_color)
{
double minVal,maxVal; minMaxIdx(verror,&minVal,&maxVal,0,0,status);
int line_thickness = 1;

for (size_t i = 0; i < prevPts.size(); ++i) 
{ 
    if (status[i]) 
    {   
                    double alpha = intrpmnmx(verror[i],minVal,maxVal); alpha = 1.0 - alpha; 
                    Scalar line_color(alpha*_line_color[0], 
                                                      alpha*_line_color[1], 
                                                      alpha*_line_color[2]); 

        Point p = prevPts[i]; 
        Point q = nextPts[i]; 

        double angle = atan2((double) p.y - q.y, (double) p.x - q.x); 

        double hypotenuse = sqrt( (double)(p.y - q.y)*(p.y - q.y) + (double)(p.x - q.x)*(p.x - q.x) ); 

        if (hypotenuse < 1.0) 
            continue; 

        // Here we lengthen the arrow by a factor of three. 
        q.x = (int) (p.x - 3 * hypotenuse * cos(angle)); 
        q.y = (int) (p.y - 3 * hypotenuse * sin(angle)); 

        // Now we draw the main line of the arrow. 
        line(frame, p, q, line_color, line_thickness); 

        // Now draw the tips of the arrow. I do some scaling so that the 
        // tips look proportional to the main line of the arrow. 

        p.x = (int) (q.x + 9 * cos(angle + CV_PI / 4)); 
        p.y = (int) (q.y + 9 * sin(angle + CV_PI / 4)); 
        line(frame, p, q, line_color, line_thickness); 

        p.x = (int) (q.x + 9 * cos(angle - CV_PI / 4)); 
        p.y = (int) (q.y + 9 * sin(angle - CV_PI / 4)); 
        line(frame, p, q, line_color, line_thickness); 
    } 
} 

}

bool hasEnding (std::string const &fullString, std::string const &ending)
{
if (fullString.length() >= ending.length()) {
return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending));
} else {
return false;
}
}

bool hasEndingLower (string const &fullString_, string const &ending)
{
string fullstring = fullString
, ending = ending;
transform(fullString
.begin(),fullString_.end(),fullstring.begin(),::tolower); // to lower
return hasEnding(fullstring,ending);
}

void imshow_250x250(const string& name_, const Mat& patch) {
Mat bigpatch; cv::resize(patch,bigpatch,Size(250,250));
imshow(name_,bigpatch);
}

void open_imgs_dir(char* dir_name, std::vectorcv::Mat& images, std::vectorstd::string& images_names, double downscale_factor) {
if (dir_name == NULL) {
return;
}

    string dir_name_ = string(dir_name); 
    vector<string> files_; 

ifndef WIN32

//open a directory the POSIX way

    DIR *dp; 
    struct dirent *ep;     
    dp = opendir (dir_name); 

    if (dp != NULL) 
    { 
            while (ep = readdir (dp)) { 
                    if (ep->d_name[0] != '.') 
                            files_.push_back(ep->d_name); 
            } 

            (void) closedir (dp); 
    } 
    else { 
            cerr << ("Couldn't open the directory"); 
            return; 
    } 

else

//open a directory the WIN32 way
HANDLE hFind = INVALID_HANDLE_VALUE;
WIN32_FIND_DATA fdata;

    if(dir_name_[dir_name_.size()-1] == '\\' || dir_name_[dir_name_.size()-1] == '/') { 
            dir_name_ = dir_name_.substr(0,dir_name_.size()-1); 
    } 

    hFind = FindFirstFile(string(dir_name_).append("\\*").c_str(), &fdata); 
    if (hFind != INVALID_HANDLE_VALUE) 
    { 
            do 
            { 
                    if (strcmp(fdata.cFileName, ".") != 0 && 
                            strcmp(fdata.cFileName, "..") != 0) 
                    { 
                            if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 
                            { 
                                    continue; // a diretory 
                            } 
                            else 
                            { 
                                    files_.push_back(fdata.cFileName); 
                            } 
                    } 
            } 
            while (FindNextFile(hFind, &fdata) != 0); 
    } else { 
            cerr << "can't open directory\n"; 
            return; 
    } 

    if (GetLastError() != ERROR_NO_MORE_FILES) 
    { 
            FindClose(hFind); 
            cerr << "some other error with opening directory: " << GetLastError() << endl; 
            return; 
    } 

    FindClose(hFind); 
    hFind = INVALID_HANDLE_VALUE; 

endif

    for (unsigned int i=0; i<files_.size(); i++) { 
            if (files_[i][0] == '.' || !(hasEndingLower(files_[i],"jpg")||hasEndingLower(files_[i],"png"))) { 
                    continue; 
            } 
            cv::Mat m_ = cv::imread(string(dir_name_).append("/").append(files_[i])); 
            if(downscale_factor != 1.0) 
                    cv::resize(m_,m_,Size(),downscale_factor,downscale_factor); 
            images_names.push_back(files_[i]); 
            images.push_back(m_); 
    } 

}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Is some header file missing ????? Actually i dont have a file like C:\Qt\4.8.0\lib\QtGuid4.lib but i do have qt installed it is opensource it is installed in E:\OpenCV\dep\qt\qt-everywhere-opensource-src-4.8.4
and i have also installed PCL 1.6.0 All-In-One Installer but i checked it does not have Qt 4.8.0 in the 3rd party library. What should i do

Chapter 1 Android Exception

When adding the code of the section ##Showing the FPS of the app, a device does not run the application generates the exception:

12-24 20:39:32.922: W/dalvikvm(8785): No implementation found for native Lorg/opencv/core/Core;.getTickFrequency_0 ()D
12-24 20:39:32.926: D/AndroidRuntime(8785): Shutting down VM
12-24 20:39:32.926: W/dalvikvm(8785): threadid=1: thread exiting with uncaught exception (group=0x4001d7d0)
12-24 20:39:32.930: E/AndroidRuntime(8785): FATAL EXCEPTION: main
12-24 20:39:32.930: E/AndroidRuntime(8785): java.lang.UnsatisfiedLinkError: getTickFrequency_0 

bug-fix Ch4 SfM: suggest remove non-existent namespace cv::core, GPUSURFFeatureMatcher.cpp, near line 23

Severity: build fail
Issue: Chapter 4, Exploring SfM, GPUSURFFeatureMatcher.cpp references non-existing namespace cv::core in tested opencv versions of /include/opencv2/core/core.hpp
Tested OpenCV2.3.x or higher on Unix (Linux/Mac)
Suggested bug-fix: comment-out or remove the line "using namespace cv::core" (near line 23) of GPUSURFFeatureMatcher.cpp
Comment: builds and runs OK after suggested bug-fix. -Antony

How to build my own OpenCV package under Ubuntu 14.04 ?

I installed OpenCV following this official documentation. Everything is fine. However, when I set the flag of a window to use OpenGL, I get this error:

OpenCV Error: No OpenGL support (Library was built without OpenGL support) in CvWindow

The solution is to build my own OpenCV package as stated:

The precompiled OpenCV you can download from opencv.org build without
OpenGL support. In order to run this sample you may want to build your
own OpenCV package.

The problem is that the official documentation shows how to built my own OpenCV package under Windows. How to do the same thing on Ubuntu 14.04 to use it from Python ?

Thank you in advance for any helpful hints.
BEGUERADJ.

Can't Compile on Ubuntu

Hello,

At the first, Thanks for sharing your knowledge.

I can't compile the chapter 8 code.

After command "cmake -D OpenCV_DIR=$OpenCV_DIR ..", show the following message:

CMake Error: The source directory "/home/myfolder/code-master" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

My opencv version is 2.4.8 on Ubuntu 14.04

Regards,
Marcelo

Offline mode recognition CHapter 8

Excuse me. Before i use your new code in this book, I read your page: http://www.shervinemami.info/faceRecognition.html

and i see the tutorial and code working in offline mode in Servo Magazine page show how to recognize faces from image:
http://www.cognotics.com/opencv/servo_2007_series/part_5/index.html

I built the code as instruction. The program did not report any errors. But when i run the program, the black window appeared and disappeared right after that and not show the window to type the command. I don't understand why. I had the necessary files. The output when i buit shows that "Could not find or open pdb file".
What happened? Could you show me how to fix this problem?
And can i use your system face recognition in shervinemami.info in both online and offline mode ?
Thanks for reading and help.

kd - tree generation for SiftGPU

Hi i am trying to write an OpenCV code to generate a kd-tree for SiftGPU features based on SiftGPU of http://cs.unc.edu/~ccwu/siftgpu/. Its like I have generate keyframes which are keyoints that is reconstructed in 3D for which the SiftGPU features are extracted and the kd - tree is generated. I started from the SiftGPU feature extraction but when i try to store it in the kd-tree I get Assertion error problem.

I tried every possible way but I still get the Assertion errors during runtime like
OpenCV Error: Assertion failed (data.dims <= 2 && type == CV_32F && K > 0) in unknown function, file ......\OpenCV-2.3.0\modules\core\src\matrix.cpp, line 2271

and when i change the code accordingly I get the error
opencv error assertion failed (data type<_Tp>::Type=type == type &&cols==1)

I really need some help with the code work I need help from scratch because I need to use the code in other places also. Is there anywhere I can refer to get a clear idea on how to generate the code .Its urgent cause I have a dead line by day after tomorrow. So please help.

Error when running chapter 5 code - ANPR

I was able to successfully build the code in Windows 8 with OpenCV 2.4.5. But when I run the ANPR.exe following error returned. What may be the reason. Thank you.

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

Automatic Number Plate Recognition project( igaspard/ANPR) in windows getting errors

Hi,
I am new to OCR and I am trying to run sample code of Automatic Number Plate Recognition project(
igaspard/ANPR) in windows . Taking the sample code I have created 4 individual program

  1. main application using main.cpp,
  2. trainOCR using trainOCR.cpp
  3. trainSVM using trainSVM.cpp and
  4. evalOCR using evalOCR.cpp.
    (NOTE: each above cpp having main function that’s why I created 4 project).

I do not have any idea which project I should run first and what input I should to assign for the each project.

When I try to run the individual application with input as 2715DTZ.jpg(test folder of sample data)
I am getting different error.

  1. Like from main project error
    OpenCV Automatic Number Plate Recognition
    working with file:
    OpenCV Error: Bad argument (train data must be floating-point matrix) in cvCheckTrainData, file C:/slave/builds/WinInstallerMegaPack/src/opencv/m
    odules/ml/src/inner_functions.cpp, line 857
    terminate called after throwing an instance of 'cv::Exception'
    what(): C:/slave/builds/WinInstallerMegaPack/src/opencv/modules/ml/src/inner_functions.cpp:857: error: (-5) train data must be floating-point
    matrix in function cvCheckTrainData

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

  1. from trainOCR project error
    Character 0 file: 0
    OpenCV Error: Assertion failed (ssize.area() > 0) in resize, file C:/slave/builds/WinInstallerMegaPack/src/opencv/modules/imgproc/src/imgwarp.cpp
    , line 1725
    terminate called after throwing an instance of 'cv::Exception'
    what(): C:/slave/builds/WinInstallerMegaPack/src/opencv/modules/imgproc/src/imgwarp.cpp:1725: error: (-215) ssize.area() > 0 in function resize

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

  1. from trainSVM project error
    OpenCV Training SVM Automatic Number Plate Recognition
    Usage:
    trainSVM.exe
  2. From evalOCR project error
    terminate called after throwing an instance of 'std::out_of_range'
    what(): vector::_M_range_check

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

I do not understand what sequence I should run the application and what should be input.

So please kindly suggest me how can I overcome all the above issue using the same sample code or is there any other way to create the project? I am not figuring out what is issue from my side.

Thanks & regards
Anil

Could't grap the next frame !

I used the laptop with an integrated web camera. When i run the program, it reported "Couldn't grap the next camera frame", the window showing image from camera apeared then disappeared immediatly. I plug another web camera to connect with laptop by the USB. But the same error occured. How can i fix this problem ?

Chapter 3: Performance issues, do you get realtime tracking?

Hello everybody,

I'm running Chapter 3: Marker-less Augmented Reality from this great book on a laptop with an Intel i7, 6GB RAM, nVidia 540 Graphics and I get like 1FPS, which is totally unacceptable for any realtime application...
I tried capturing @ 640x480, tried several cams and even tried a captured video as input to eliminate any lag introduced by webcam capture. Running the release build instead of debug speeds it up a little but still is amazingly slow.

When I run other markerless implementations like BazAR ( http://cvlab.epfl.ch/cms/site/cvlab2/lang/en/software/bazar ), they run perfect and at full speed.
Even my Galaxy Note 2 does AR realtime, for example the Augment app ( https://play.google.com/store/apps/details?id=com.ar.augment&hl=en ) does perfect tracking in realtime when using "Create Tracker" and taking a picture of magazine cover lying around.

Is this code not suited for realtime applications or am I doing something wrong?

Thx,
ucf

Chapter 3 Markerless AR with VS 2010 and OpenCV 2.4.6 on Win7 x64

Hi,
I followed all steps in Readme to run this project. I even re-built OpenCV with OpenGL enabled. However, I get following error when i run the markerless_ar_demo.exe:
markerless_ar_demo_error
(the application was unable to start correctly (0xc000007b). Click OK to continue)

Also, I am unable to debug the app because I get the following error on pressing debug button:
debug_error

Any clues?
Thanks.

Chapter 8 How to run

Excuse me. Anyone can help me how to run clearly by the main program Visual Studio 2010? If i build the "main.cpp", where must i put the files: detectoject.h, detectOject.cpp,... and the other files in the list of codes?
I try to build, but the program reported the error:

"Error 1 error LNK2019: unresolved external symbol "class cv::Mat __cdecl reconstructFace(class cv::Ptr,class cv::Mat)" (?reconstructFace@@ya?AVMat@cv@@v?$Ptr@VFaceRecognizer@cv@@@2@V12@@z) referenced in function "void __cdecl recognizeAndTrainUsingWebcam(class cv::VideoCapture &,class cv::CascadeClassifier &,class cv::CascadeClassifier &,class cv::CascadeClassifier&)" (?recognizeAndTrainUsingWebcam@@YAXAAVVideoCapture@cv@@AAVCascadeClassifier@2@11@Z) C:\Users\El Nino\Documents\Visual Studio 2010\Projects\facerecmain\facerecmain\facerec.obj"
Thanks so much.
and how can i use the cmake to run the program as the read me file tell ?

Combine 2 projects

Hi if I were to combine the 2 projects of Chapter 3 and Chapter 4 how would i do it would I have to do it manually or is there any other way using cmake to combine the two projects. If I were to do it manually do it will I have to add additional lines to it.

Bug in FindCameraMatrices

Just take a close look to the matches vector in FindCameraMatrices.cpp (line 162)

    DMatch(matches[i].queryIdx,matches[i].trainIdx,matches[i].distance)

will fail because i is out of bounds.

if (matches.size() <= 0) { //points already aligned...
new_matches.push_back(DMatch(matches[i].queryIdx,matches[i].trainIdx,matches[i].distance));
} else {
new_matches.push_back(matches[i]);
}

Chapter 4 :Structure From Motion

Hi, I am trying yo configure the structure from motion code but i get the configuration error that project file may be invalid. During configuration
Performing Test OpenMP_FLAG_DETECTED - Failed

Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
Boost version: 1.48.0
Found the following Boost libraries:
system
filesystem
thread
date_time
iostreams
looking for PCL_COMMON
looking for PCL_OCTREE
looking for PCL_IO
looking for PCL_SAMPLE_CONSENSUS
looking for PCL_KDTREE
looking for PCL_SEARCH
looking for PCL_FILTERS
looking for PCL_SEGMENTATION
looking for PCL_VISUALIZATION
looking for PCL_FEATURES
looking for PCL_SURFACE
looking for PCL_REGISTRATION
looking for PCL_KEYPOINTS
looking for PCL_TRACKING
looking for PCL_APPS
will use Eigen
Try OpenMP C flag = [/openmp]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP C flag = [ ]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP C flag = [-fopenmp]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP C flag = [-Qopenmp]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP C flag = [-openmp]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP C flag = [-xopenmp]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP C flag = [+Oopenmp]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP C flag = [-qsmp]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP C flag = [-mp]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP CXX flag = [/openmp]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP CXX flag = [ ]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP CXX flag = [-fopenmp]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP CXX flag = [-Qopenmp]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP CXX flag = [-openmp]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP CXX flag = [-xopenmp]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP CXX flag = [+Oopenmp]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP CXX flag = [-qsmp]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
Try OpenMP CXX flag = [-mp]
Performing Test OpenMP_FLAG_DETECTED
CMake Warning (dev) in C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:
Syntax Warning in cmake code at

C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeTmp/CMakeLists.txt:2:45

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

Performing Test OpenMP_FLAG_DETECTED - Failed
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find OpenMP (missing: OpenMP_C_FLAGS OpenMP_CXX_FLAGS)
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindOpenMP.cmake:162 (find_package_handle_standard_args)
CMakeLists.txt:14 (find_package)

Configuring incomplete, errors occurred!
See also "C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Reeba/Desktop/Chapter4_StructureFromMotion/src/CMakeFiles/CMakeError.log".

i dont know what to include for the field
OpenMP_CXX_FLAGS
OpenMP_C_FLAGS
in cmake

I have cygwin64 installed and the gcc folder in C:\cygwin64\lib\gcc has the following folder
i686-pc-cygwin
i686-pc-mingw32
i686-w64-mingw32
x86_64-pc-cygwin
x86_64-w64-mingw32

I dont know what to add for the above two fields. Is there anything i should install ?? or Is it because it installed PCL version 1.5.1 instead of 1.6 cause i am using Visual Studio 2008 Express Edition version 9 and my opencv version is 2.4.4 ? Is it necessary to use v1.6 or above.for PCL. I downloaded the version PCL 1.5.1 PCL 1.5.1 All-In-One Installer from http://sourceforge.net/projects/pointclouds/files/1.5.1/PCL-1.5.1-AllInOne-msvc2008-win32.exe/download (is it ok to use it).
Please help ? Its urgent!! Am stuck with cmake configuration
Its urgent i get the code working its not been working for a long time .
If someone has any ideas please reply am new to cmake

Distortion effect in Chapter 4

Hi,

I have been debugging the example of chapter 4 and I have one doubt about how the distortion is managed in the code.

In the code there are some references to the undistortpoints function, but all of them are commented so I asume that no correction for distortion is done.

In the chapter I haven't either found any comment about this, and in the "Finding camera matrices" subchapter of the book the except code calculates the F matrix directly from the matched points.

As there is an option in the code to read the calibration parameters from file so I asume that no undistorted images have to be used.

The question is that the reprojection error that I have when using undistorted the images is a Little bit higher tan when I run the code directly. Does it make sense or I should check the calibration process ?

Another issue I have found is that in order to check if the essential matrix is properly computed, the determinant(E) is compared with 1e-07 but for big images (3972x2592), the determinant of K is so big that it makes to fail the comparation, even having a determinant(F) around 1e-21

Regards

Carlos

RGB video source problem

Hi the PTAMM code started to work finally in Windows and I was finally able to get the video source from usb web cam using the code

include “VideoSource.h”

//#include

include

include

include

include

include

include

using namespace CVD;
using namespace std;
using namespace GVars3;
using namespace cv;

define OPENCV_VIDEO_W 640

define OPENCV_VIDEO_H 480

namespace PTAMM
{
VideoSource::VideoSource()
{
cout << " VideoSource_Linux: Opening video source…" <isOpened()){
cerr << "Unable to get the camera" << endl;
exit(-1);
}
cout << " … got video source." << endl;
mirSize = ImageRef(OPENCV_VIDEO_W, OPENCV_VIDEO_H);
};

ImageRef VideoSource::Size()
{
return mirSize;
};

void conversionNB(Mat frame, Image &imBW){
Mat clone = frame.clone();
Mat_& frame_p = (Mat_&)clone;
for (int i = 0; i < OPENCV_VIDEO_H; i++){
for (int j = 0; j < OPENCV_VIDEO_W; j++){
imBW[i][j] = (frame_p(i,j)[0] + frame_p(i,j)[1] + frame_p(i,j)[2]) / 3;
}
}

}

void conversionRGB(Mat frame, Image &imRGB){
Mat clone = frame.clone();
Mat_& frame_p = (Mat_&)clone;
for (int i = 0; i < OPENCV_VIDEO_H; i++){
for (int j = 0; j < OPENCV_VIDEO_W; j++){
imRGB[i][j].red = frame_p(i,j)[2];
imRGB[i][j].green = frame_p(i,j)[1];
imRGB[i][j].blue = frame_p(i,j)[0];
}
}
}

void VideoSource::GetAndFillFrameBWandRGB(Image &imBW, Image &imRGB)
{
Mat frame;
VideoCapture* cap = (VideoCapture*)mptr;
*cap >> frame;
conversionNB(frame, imBW);
conversionRGB(frame, imRGB);
}
}

But the video source for PTAMM is black and white how do I get the an RGB video source instead of a gray image as video source. I think I need to add the line cvCvtColor(&frame,&frame,CV_GRAY2BGR);

but it dosnt work cause I get OpenCV assertion error. Could someone tell me how do I get RGB type video Input Source.

Problems finding cv::gpu::SURF_GPU

I'm still relatively new to c++ so I've managed to run in trouble when trying to compile the code from Chapter4. I'm using MSVS 2010 Pro and I've got opencv 2.4.6 and PCL 1.6.0.

Here is the output I'm getting:

2>------ Build started: Project: ExploringSfMLibrary, Configuration: Debug x64 ------
2>Build started 02/08/2013 18:51:55.
2>InitializeBuildStatus:
2>  Touching "ExploringSfMLibrary.dir\Debug\ExploringSfMLibrary.unsuccessfulbuild".
2>CustomBuild:
2>  All outputs are up-to-date.
2>ClCompile:
2>  MultiCameraDistance.cpp
2>c:\users\hm\downloads\masteringopencv\chapter4_structurefrommotion\GPUSURFFeatureMatcher.h(14): error C2039: 'SURF_GPU' : is not a member of 'cv::gpu'
2>c:\users\hm\downloads\masteringopencv\chapter4_structurefrommotion\GPUSURFFeatureMatcher.h(14): error C2065: 'SURF_GPU' : undeclared identifier
2>..\MultiCameraDistance.cpp(86): warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
2>..\MultiCameraDistance.cpp(86): warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
2>  Common.cpp
2>..\Common.cpp(166): error C2065: 'HANDLE' : undeclared identifier
2>..\Common.cpp(166): error C2146: syntax error : missing ';' before identifier 'hFind'
2>..\Common.cpp(166): error C2065: 'hFind' : undeclared identifier
2>..\Common.cpp(166): error C2065: 'INVALID_HANDLE_VALUE' : undeclared identifier
2>..\Common.cpp(167): error C2065: 'WIN32_FIND_DATA' : undeclared identifier
2>..\Common.cpp(167): error C2146: syntax error : missing ';' before identifier 'fdata'
2>..\Common.cpp(167): error C2065: 'fdata' : undeclared identifier
2>..\Common.cpp(173): error C2065: 'hFind' : undeclared identifier
2>..\Common.cpp(173): error C2065: 'fdata' : undeclared identifier
2>..\Common.cpp(173): error C3861: 'FindFirstFile': identifier not found
2>..\Common.cpp(174): error C2065: 'hFind' : undeclared identifier
2>..\Common.cpp(174): error C2065: 'INVALID_HANDLE_VALUE' : undeclared identifier
2>..\Common.cpp(178): error C2065: 'fdata' : undeclared identifier
2>..\Common.cpp(178): error C2228: left of '.cFileName' must have class/struct/union
2>          type is ''unknown-type''
2>..\Common.cpp(179): error C2065: 'fdata' : undeclared identifier
2>..\Common.cpp(179): error C2228: left of '.cFileName' must have class/struct/union
2>          type is ''unknown-type''
2>..\Common.cpp(181): error C2065: 'fdata' : undeclared identifier
2>..\Common.cpp(181): error C2228: left of '.dwFileAttributes' must have class/struct/union
2>          type is ''unknown-type''
2>..\Common.cpp(181): error C2065: 'FILE_ATTRIBUTE_DIRECTORY' : undeclared identifier
2>..\Common.cpp(187): error C2065: 'fdata' : undeclared identifier
2>..\Common.cpp(187): error C2228: left of '.cFileName' must have class/struct/union
2>          type is ''unknown-type''
2>..\Common.cpp(191): error C2065: 'hFind' : undeclared identifier
2>..\Common.cpp(191): error C2065: 'fdata' : undeclared identifier
2>..\Common.cpp(191): error C3861: 'FindNextFile': identifier not found
2>..\Common.cpp(197): error C2065: 'ERROR_NO_MORE_FILES' : undeclared identifier
2>..\Common.cpp(197): error C3861: 'GetLastError': identifier not found
2>..\Common.cpp(199): error C2065: 'hFind' : undeclared identifier
2>..\Common.cpp(199): error C3861: 'FindClose': identifier not found
2>..\Common.cpp(200): error C3861: 'GetLastError': identifier not found
2>..\Common.cpp(204): error C2065: 'hFind' : undeclared identifier
2>..\Common.cpp(204): error C3861: 'FindClose': identifier not found
2>..\Common.cpp(205): error C2065: 'hFind' : undeclared identifier
2>..\Common.cpp(205): error C2065: 'INVALID_HANDLE_VALUE' : undeclared identifier
2>  BundleAdjuster.cpp
2>..\BundleAdjuster.cpp(17): fatal error C1083: Cannot open include file: 'Math/v3d_linear.h': No such file or directory
2>  GPUSURFFeatureMatcher.cpp
2>c:\users\hm\downloads\masteringopencv\chapter4_structurefrommotion\GPUSURFFeatureMatcher.h(14): error C2039: 'SURF_GPU' : is not a member of 'cv::gpu'
2>c:\users\hm\downloads\masteringopencv\chapter4_structurefrommotion\GPUSURFFeatureMatcher.h(14): error C2065: 'SURF_GPU' : undeclared identifier
2>..\GPUSURFFeatureMatcher.cpp(29): error C2512: 'cv::Ptr' : no appropriate default constructor available
2>..\GPUSURFFeatureMatcher.cpp(33): error C2039: 'SURF_GPU' : is not a member of 'cv::gpu'
2>..\GPUSURFFeatureMatcher.cpp(33): error C2061: syntax error : identifier 'SURF_GPU'
2>..\GPUSURFFeatureMatcher.cpp(46): error C2100: illegal indirection
2>..\GPUSURFFeatureMatcher.cpp(46): error C2064: term does not evaluate to a function taking 4 arguments
2>  Generating Code...
2>
2>Build FAILED.
2>
2>Time Elapsed 00:00:02.95
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Any hints on how I could continue compiling the project ?

Chapter 6 issues

There are a few problems with the code for Chapter 6. The readme says --help returns some helpful information, but it is not recognized.
All of the commands apparently need additional inputs which are not clearly described and are not provided as an example. It is unclear what is needed in annotation files, shape models, detector files, etc. I assume some of these can be created with the training executables, but there is no information or examples of the files or how to run the executables, or their outputs.
Can more code/example files be provided or more information be added to the readme?

Chapter 4 Crash on OSX

I build the example in Chapter 4 on my machine running OSX Mavericks.
My images were rather large, and high-def (from iPhone camera)
There were 20-30 of them.
I built the Debug version of the project in XCode.
After image files were loaded, and either after or during feature-detection and matching(I may be wrong about this, but it did not get to printing P and E matrices), the process froze and nearly crashed my computer after printing this error message:

2014-11-01 01:14:19.000 ExploringSFMExec[50530:1f03] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /SourceCache/Foundation/Foundation-1056.16/Misc.subproj/NSUndoManager.m:328
2014-11-01 01:14:22.919 ExploringSFMExec[50530:1f03] +[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.
2014-11-01 01:14:33.248 ExploringSFMExec[50530:1f03](0 CoreFoundation 0x00007fff929a025c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8dfb5e75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff929a0038 +[NSException raise:format:arguments:] + 104
3 Foundation 0x00007fff9155f3d1 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
4 Foundation 0x00007fff914c991c +[NSUndoManager%28NSPrivate%29 _endTopLevelGroupings] + 156
5 AppKit 0x00007fff98923a23 -[NSApplication run] + 688
6 libpcl_visualization.1.7.dylib 0x000000010fd6ffae _ZN3pcl13visualization13PCLVisualizer8spinOnceEib + 280
7 ExploringSFMExec 0x00000001071d6954 _Z20RunVisualizationOnlyv + 5044
8 ExploringSFMExec 0x00000001071f4bf6 _ZN5boost6detail11thread_dataIPFvvEE3runEv + 22
9 libboost_thread-mt.dylib 0x00000001080b2d05 _ZN5boost12_GLOBAL__N_112thread_proxyEPv + 133
10 libsystem_pthread.dylib 0x00007fff90699899 _pthread_body + 138
11 libsystem_pthread.dylib 0x00007fff9069972a _pthread_struct_init + 0
12 libsystem_pthread.dylib 0x00007fff9069dfc9 thread_start + 13)
2014-11-01 01:14:34.049 ExploringSFMExec[50530:1f03] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /SourceCache/Foundation/Foundation-1056.16/Misc.subproj/NSUndoManager.m:328
2014-11-01 01:14:34.280 ExploringSFMExec[50530:1f03] An uncaught exception was raised
2014-11-01 01:14:34.783 ExploringSFMExec[50530:1f03] +[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.
2014-11-01 01:14:34.784 ExploringSFMExec[50530:1f03](0 CoreFoundation 0x00007fff929a025c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8dfb5e75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff929a0038 +[NSException raise:format:arguments:] + 104
3 Foundation 0x00007fff9155f3d1 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
4 Foundation 0x00007fff914c991c +[NSUndoManager%28NSPrivate%29 _endTopLevelGroupings] + 156
5 AppKit 0x00007fff98923acd -[NSApplication run] + 858
6 libpcl_visualization.1.7.dylib 0x000000010fd6ffae _ZN3pcl13visualization13PCLVisualizer8spinOnceEib + 280
7 ExploringSFMExec 0x00000001071d6954 _Z20RunVisualizationOnlyv + 5044
8 ExploringSFMExec 0x00000001071f4bf6 _ZN5boost6detail11thread_dataIPFvvEE3runEv + 22
9 libboost_thread-mt.dylib 0x00000001080b2d05 _ZN5boost12_GLOBAL__N_112thread_proxyEPv + 133
10 libsystem_pthread.dylib 0x00007fff90699899 _pthread_body + 138
11 libsystem_pthread.dylib 0x00007fff9069972a _pthread_struct_init + 0
12 libsystem_pthread.dylib 0x00007fff9069dfc9 thread_start + 13)
2014-11-01 01:14:34.896 ExploringSFMExec[50530:1f03] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff929a025c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8dfb5e75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff929a0038 +[NSException raise:format:arguments:] + 104
3 Foundation 0x00007fff9155f3d1 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
4 Foundation 0x00007fff914c991c +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 156
5 AppKit 0x00007fff98923acd -[NSApplication run] + 858
6 libpcl_visualization.1.7.dylib 0x000000010fd6ffae _ZN3pcl13visualization13PCLVisualizer8spinOnceEib + 280
7 ExploringSFMExec 0x00000001071d6954 _Z20RunVisualizationOnlyv + 5044
8 ExploringSFMExec 0x00000001071f4bf6 _ZN5boost6detail11thread_dataIPFvvEE3runEv + 22
9 libboost_thread-mt.dylib 0x00000001080b2d05 _ZN5boost12_GLOBAL__N_112thread_proxyEPv + 133
10 libsystem_pthread.dylib 0x00007fff90699899 _pthread_body + 138
11 libsystem_pthread.dylib 0x00007fff9069972a _pthread_struct_init + 0
12 libsystem_pthread.dylib 0x00007fff9069dfc9 thread_start + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException

( In addition to this issue, I have a few more questions about this chapter's code, which might be very useful to my undergraduate thesis project if I can figure out a few details that aren't covered in the book.
Is there a better place to contact you? )

Chapter 3: Detection And Tracking

I can I make the process of detection and tracking parallel for the code in Chapter 3 along with keyframe generation . I really want some advice on this.
Please Help

OpenCV: libdc1394 error: Failed to initialize libdc1394

I installed OpenCV correctly on Ubuntu 14.04. However, when I run: import cv2 I get this error message:

>>> import cv2
libdc1394 error: Failed to initialize libdc1394

I read the answers fro a similar question, but all of them assume the existence of this file which I don't have: /dev/raw1394. So I installed the library:

sudo apt-get install libdc1394-22-dev libdc1394-22 libdc1394-utils

But still get the same error.

Note that this answer is the only one that works for me, however I can not pick it because I need to use camera in my application.

How can I resolve this ?

Thank you in advance.
Begueradj

Ch4: Crashes in GetFundamentalMat(,,,)

When GetFundamentalMat() from FindCameraMatrices.cpp is called, and matches.size() == 0 it crashes. I found two places, where it usually crashes.

First:
FindCameraMatrices.cpp, string 151:

F = findFundamentalMat(pts1, pts2, FM_RANSAC, 0.006 * maxVal, 0.99, status); //threshold from [Snavely07 4.1]

crashes, because pts1 and pts2 have to be the same size, but they don't. And they don't because of:

FindCameraMatrices.cpp, string 132:

if (matches.size() <= 0 ) { 
        //points already aligned...
        imgpts1_tmp = imgpts1;
        imgpts2_tmp = imgpts2;
}

Crash occures if matches.size() == 0, but size of imgpts1 != size of imgpts2.

Second:
FindCameraMatrices.cpp, string 162:

if (matches.size() <= 0) { //points already aligned...
new_matches.push_back(DMatch(matches[i].queryIdx,matches[i].trainIdx,matches[i].distance));

matches.size() == 0, but we are going to retreive matches[i].

OpenCV issue : No OpenGL support(Library built without OpenGL support) in cvNamedWIndows ,file .\ \\opencv\modules\highgui\src\window_w32.cpp line 746

I am trying the code for Markerless AR in Visual Studio 2008 with OpenCV 2.4.4 in Windows 7but i come across this error. I have configured everything needed for the code. I downloaded Opencv 2.4.4.exe from sourceforge and enabled OpenGL using cmake but it still shows error.
It shows the same error for the function:
cv::namedWindow(windowName, cv::WINDOW_OPENGL);
cv::setOpenGlContext(windowName);
cv::setOpenGlDrawCallback(windowName, ARDrawingContextDrawCallback, this);
I use the Intel graphics(Generic PnP Monitor on Intel HD Graphics 4000 Driver version 10.18.10.3345)
I also tried the same code in Nvidia system which showed the same error.
I would really like it if i could a stepwise instruction on how to setup the markerless ar project and solve the OpenGL support problem.
I fell its a code error
I have a deadline of 2 days to complete the code I could use all the help i can get .
Please Help!!!
1

C5 ANPR

Just tested the program but
error C4716: 'generateRandom' : must return a value

Chapter3 MarkerlessAR

I'm trying to run this on Mac (Mountain Lion) with OpenCV 2.4.5
I'm getting the following error:

OpenCV Error: No OpenGL support (Library was built without OpenGL support) in CvWindow

When trying to build with OpenGL the option does not show up in cmake. The latest is configured not to have openGL (CMakeLists.txt line 131)

OCV_OPTION(WITH_OPENGL         "Include OpenGL support"                      OFF  IF (NOT ANDROID AND NOT APPLE) )

I've even tried to brew OpenCV with the QT option, but I get the same error still.
How can I run this on mac, if I can't compile it with OpenGL?

Chapter 6 - Chapter 7 Disconnect

There seems to be a disconnect between chapters 6 and 7. Chapter 6 describes a process for tracking and fitting a deformable model in an image. Chapter 7 describes a process for extracting a pose for a 3D model from an image. However, there is no description on how to convert the deformable model into a 3D model. Jason's has published work which uses deformable models to extract a pose (position and orientation) from images, but that process is lacking from the book and that functionality is missing from the code. Might it be possible for that functionality to be added?

poor performance of ch3 markerless AR

Hi all, I just run ch3 markerless AR sample. Unfortunately, I find the performance is poor even with suggested PyramidPattern.jpg. The cube is flying/flashing everywhere while I adjust the threshold and barely stay the right position.

On the other hand, metaio even Vuforia on the phone performs well with image.

I know that this is codes 2 years ago. where is a good start, detailed sample code for a deepdive of AR?

discussions are welcome.

Chapter8-recognition.cpp error

void showTrainingDebugData(const Ptr model, const int faceWidth, const int faceHeight)
{
try { // Surround the OpenCV calls by a try/catch block so we don't crash if some model parameters aren't available.

    // Show the average face (statistical average for each pixel in the collected images).
   /****error: get is not a member of cv::FaceRecognizer ****/
    Mat averageFaceRow = model->get<Mat>("mean");

...
}

/***error: get is not a member of cv::FaceRecognizer ***/
Mat averageFaceRow = model->get("mean");

AAM searching and fitting in ch.7

Hellow!

At the first, I learn many skills in Open CV. Thanks!

I study an Active Appearance Model in ch 7.

After I finished 'Triangle texture warping', I study 'AAM searching and fitting' .

but 'AAM searching and fitting' has not sample code.

I understand it's algorithms approximatively. but I can't make source code.

I ask for some code or some example..

Do you share this sample code or example?

I really make a AAM. Please check this Issue.

Thank for reaidng. Have a nice day!

missing includes in ch7

main.cpp:

include "InverseCompose.h"

include "PAW.h"

include "Triangle.h"

none of them in the package

BFMatcher raises error for Python interface when crossCheck option is enabled

bf = cv2.BFMatcher(cv2.NORM_L2, crossCheck=True)
matches = bf.knnMatch(descs,descs2, k=2)

raises

in ()
24 # BFMatcher with default params
25 bf = cv2.BFMatcher(cv2.NORM_L2, crossCheck=True)
---> 26 matches = bf.knnMatch(descs,descs2, k=2)
27
28 # Apply ratio test

error: /home/retina18/Downloads/Install-OpenCV-master/Ubuntu/OpenCV/opencv-2.4.10/modules/core/src/stat.cpp:2500: error: (-215) K == 1 && update == 0 && mask.empty() in function batchDistance

If I remove crossCheck option this works fine but I really need cross checking :(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.