Commit c4631573 authored by Victor Erukhimov's avatar Victor Erukhimov

cv::cvflann -> cv::flann

parent 583a08d5
...@@ -62,10 +62,6 @@ ...@@ -62,10 +62,6 @@
#if defined(__cplusplus) #if defined(__cplusplus)
#include "opencv2/core/internal.hpp" #include "opencv2/core/internal.hpp"
namespace cv {
namespace flann = cvflann;
}
#endif //__cplusplus #endif //__cplusplus
#endif __OPENCV_OLD_CV_H_ #endif __OPENCV_OLD_CV_H_
...@@ -43,6 +43,10 @@ ...@@ -43,6 +43,10 @@
#ifndef __OPENCV_OLD_CV_HPP__ #ifndef __OPENCV_OLD_CV_HPP__
#define __OPENCV_OLD_CV_HPP__ #define __OPENCV_OLD_CV_HPP__
#if defined(__GNUC__)
#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
#endif
#include <cv.h> #include <cv.h>
#endif #endif
...@@ -42,8 +42,9 @@ ...@@ -42,8 +42,9 @@
#ifndef __OPENCV_OLD_AUX_H__ #ifndef __OPENCV_OLD_AUX_H__
#define __OPENCV_OLD_AUX_H__ #define __OPENCV_OLD_AUX_H__
#pragma warning("This is a deprecated opencv header provided for compatibility. Please \ #if defined(__GNUC__)
include a header from a corresponding opencv module") #warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
#endif
#include "opencv2/core/core_c.h" #include "opencv2/core/core_c.h"
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
......
...@@ -42,6 +42,10 @@ ...@@ -42,6 +42,10 @@
#ifndef __OPENCV_OLD_AUX_HPP__ #ifndef __OPENCV_OLD_AUX_HPP__
#define __OPENCV_OLD_AUX_HPP__ #define __OPENCV_OLD_AUX_HPP__
#if defined(__GNUC__)
#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
#endif
#include <cvaux.h> #include <cvaux.h>
#endif #endif
...@@ -43,6 +43,10 @@ ...@@ -43,6 +43,10 @@
#ifndef __OPENCV_OLD_CXCORE_H__ #ifndef __OPENCV_OLD_CXCORE_H__
#define __OPENCV_OLD_CXCORE_H__ #define __OPENCV_OLD_CXCORE_H__
#if defined(__GNUC__)
#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
#endif
#include "opencv2/core/core_c.h" #include "opencv2/core/core_c.h"
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
......
...@@ -52,7 +52,7 @@ namespace cvflann ...@@ -52,7 +52,7 @@ namespace cvflann
namespace cv { namespace cv {
namespace cvflann { namespace flann {
/* Nearest neighbor index algorithms */ /* Nearest neighbor index algorithms */
enum flann_algorithm_t { enum flann_algorithm_t {
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
namespace cv namespace cv
{ {
namespace cvflann { namespace flann {
::cvflann::Index* LinearIndexParams::createIndex(const Mat& dataset) const ::cvflann::Index* LinearIndexParams::createIndex(const Mat& dataset) const
{ {
......
...@@ -1077,7 +1077,7 @@ protected: ...@@ -1077,7 +1077,7 @@ protected:
CvMat* m_pca_hr_eigenvectors; // PCA eigenvectors for large patches CvMat* m_pca_hr_eigenvectors; // PCA eigenvectors for large patches
OneWayDescriptor* m_pca_descriptors; // an array of PCA descriptors OneWayDescriptor* m_pca_descriptors; // an array of PCA descriptors
cv::cvflann::Index* m_pca_descriptors_tree; cv::flann::Index* m_pca_descriptors_tree;
CvMat* m_pca_descriptors_matrix; CvMat* m_pca_descriptors_matrix;
CvAffinePose* m_poses; // array of poses CvAffinePose* m_poses; // array of poses
......
...@@ -149,7 +149,7 @@ namespace cv{ ...@@ -149,7 +149,7 @@ namespace cv{
std::vector<int>& desc_idxs, std::vector<int>& pose_idxs, std::vector<float>& distances, std::vector<int>& desc_idxs, std::vector<int>& pose_idxs, std::vector<float>& distances,
CvMat* avg = 0, CvMat* eigenvalues = 0); CvMat* avg = 0, CvMat* eigenvalues = 0);
void FindOneWayDescriptor(cv::cvflann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, int m_pose_count, IplImage* patch, int& desc_idx, int& pose_idx, float& distance, void FindOneWayDescriptor(cv::flann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, int m_pose_count, IplImage* patch, int& desc_idx, int& pose_idx, float& distance,
CvMat* avg = 0, CvMat* eigenvalues = 0); CvMat* avg = 0, CvMat* eigenvalues = 0);
void FindOneWayDescriptorEx(int desc_count, const OneWayDescriptor* descriptors, IplImage* patch, void FindOneWayDescriptorEx(int desc_count, const OneWayDescriptor* descriptors, IplImage* patch,
...@@ -163,7 +163,7 @@ namespace cv{ ...@@ -163,7 +163,7 @@ namespace cv{
std::vector<float>& distances, std::vector<float>& scales, std::vector<float>& distances, std::vector<float>& scales,
CvMat* avg, CvMat* eigenvectors); CvMat* avg, CvMat* eigenvectors);
void FindOneWayDescriptorEx(cv::cvflann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, int m_pose_count, IplImage* patch, void FindOneWayDescriptorEx(cv::flann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, int m_pose_count, IplImage* patch,
float scale_min, float scale_max, float scale_step, float scale_min, float scale_max, float scale_step,
int& desc_idx, int& pose_idx, float& distance, float& scale, int& desc_idx, int& pose_idx, float& distance, float& scale,
CvMat* avg, CvMat* eigenvectors); CvMat* avg, CvMat* eigenvectors);
...@@ -800,7 +800,7 @@ namespace cv{ ...@@ -800,7 +800,7 @@ namespace cv{
#if defined(_KDTREE) #if defined(_KDTREE)
void FindOneWayDescriptor(cv::cvflann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, int m_pose_count, IplImage* patch, int& desc_idx, int& pose_idx, float& distance, void FindOneWayDescriptor(cv::flann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, int m_pose_count, IplImage* patch, int& desc_idx, int& pose_idx, float& distance,
CvMat* avg, CvMat* eigenvectors) CvMat* avg, CvMat* eigenvectors)
{ {
desc_idx = -1; desc_idx = -1;
...@@ -875,7 +875,7 @@ namespace cv{ ...@@ -875,7 +875,7 @@ namespace cv{
object_ptr[i] = pca_coeffs->data.fl[i]; object_ptr[i] = pca_coeffs->data.fl[i];
} }
m_pca_descriptors_tree->knnSearch(m_object, m_indices, m_dists, 1, cv::cvflann::SearchParams(-1) ); m_pca_descriptors_tree->knnSearch(m_object, m_indices, m_dists, 1, cv::flann::SearchParams(-1) );
desc_idx = ((int*)(m_indices.ptr<int>(0)))[0] / m_pose_count; desc_idx = ((int*)(m_indices.ptr<int>(0)))[0] / m_pose_count;
pose_idx = ((int*)(m_indices.ptr<int>(0)))[0] % m_pose_count; pose_idx = ((int*)(m_indices.ptr<int>(0)))[0] % m_pose_count;
...@@ -1109,7 +1109,7 @@ namespace cv{ ...@@ -1109,7 +1109,7 @@ namespace cv{
} }
#if defined(_KDTREE) #if defined(_KDTREE)
void FindOneWayDescriptorEx(cv::cvflann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, void FindOneWayDescriptorEx(cv::flann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low,
int m_pose_count, IplImage* patch, int m_pose_count, IplImage* patch,
float scale_min, float scale_max, float scale_step, float scale_min, float scale_max, float scale_step,
int& desc_idx, int& pose_idx, float& distance, float& scale, int& desc_idx, int& pose_idx, float& distance, float& scale,
...@@ -1660,7 +1660,7 @@ namespace cv{ ...@@ -1660,7 +1660,7 @@ namespace cv{
//::cvflann::KDTreeIndexParams params; //::cvflann::KDTreeIndexParams params;
//params.trees = 1; //params.trees = 1;
//m_pca_descriptors_tree = new KDTree(pca_descriptors_mat); //m_pca_descriptors_tree = new KDTree(pca_descriptors_mat);
m_pca_descriptors_tree = new cv::cvflann::Index(pca_descriptors_mat,cv::cvflann::KDTreeIndexParams(1)); m_pca_descriptors_tree = new cv::flann::Index(pca_descriptors_mat,cv::flann::KDTreeIndexParams(1));
//cvReleaseMat(&m_pca_descriptors_matrix); //cvReleaseMat(&m_pca_descriptors_matrix);
//m_pca_descriptors_tree->buildIndex(); //m_pca_descriptors_tree->buildIndex();
} }
......
...@@ -138,8 +138,8 @@ flannFindPairs( const CvSeq*, const CvSeq* objectDescriptors, ...@@ -138,8 +138,8 @@ flannFindPairs( const CvSeq*, const CvSeq* objectDescriptors,
// find nearest neighbors using FLANN // find nearest neighbors using FLANN
cv::Mat m_indices(objectDescriptors->total, 2, CV_32S); cv::Mat m_indices(objectDescriptors->total, 2, CV_32S);
cv::Mat m_dists(objectDescriptors->total, 2, CV_32F); cv::Mat m_dists(objectDescriptors->total, 2, CV_32F);
cv::cvflann::Index flann_index(m_image, cv::cvflann::KDTreeIndexParams(4)); // using 4 randomized kdtrees cv::flann::Index flann_index(m_image, cv::flann::KDTreeIndexParams(4)); // using 4 randomized kdtrees
flann_index.knnSearch(m_object, m_indices, m_dists, 2, cv::cvflann::SearchParams(64) ); // maximum number of leafs checked flann_index.knnSearch(m_object, m_indices, m_dists, 2, cv::flann::SearchParams(64) ); // maximum number of leafs checked
int* indices_ptr = m_indices.ptr<int>(0); int* indices_ptr = m_indices.ptr<int>(0);
float* dists_ptr = m_dists.ptr<float>(0); float* dists_ptr = m_dists.ptr<float>(0);
......
...@@ -56,10 +56,24 @@ int main(int argc, char** argv) ...@@ -56,10 +56,24 @@ int main(int argc, char** argv)
IplImage* img2 = cvLoadImage(img2_name.c_str(), CV_LOAD_IMAGE_GRAYSCALE); IplImage* img2 = cvLoadImage(img2_name.c_str(), CV_LOAD_IMAGE_GRAYSCALE);
// extract keypoints from the first image // extract keypoints from the first image
vector<KeyPoint> keypoints1;
SURF surf_extractor(5.0e3); SURF surf_extractor(5.0e3);
vector<KeyPoint> keypoints1;
#if 1
Mat _img1(img1);
vector<Point2f> corners;
goodFeaturesToTrack(_img1, corners, 200, 0.01, 20);
for(size_t i = 0; i < corners.size(); i++)
{
KeyPoint p;
p.pt = corners[i];
keypoints1.push_back(p);
}
#else
// printf("Extracting keypoints\n"); // printf("Extracting keypoints\n");
surf_extractor(img1, Mat(), keypoints1); surf_extractor(img1, Mat(), keypoints1);
#endif
printf("Extracted %d keypoints...\n", (int)keypoints1.size()); printf("Extracted %d keypoints...\n", (int)keypoints1.size());
printf("Training one way descriptors..."); printf("Training one way descriptors...");
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#include <iostream> #include <iostream>
using namespace cv; using namespace cv;
using namespace cv::cvflann; using namespace cv::flann;
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
class NearestNeighborTest : public CvTest class NearestNeighborTest : public CvTest
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment