mydetector.h ( File view )

  • By YU 2014-05-21
  • View(s):91
  • Download(s):18
  • Point(s): 3
			/*M///////////////////////////////////////////////////////////////////////////////////////
//
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
//  By downloading, copying, installing or using the software you agree to this license.
//  If you do not agree to this license, do not download, install,
//  copy or use the software.
//
//
//                          License Agreement
//                For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//   * Redistribution's of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//
//   * Redistribution's in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//
//   * The name of the copyright holders may not be used to endorse or promote products
//     derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/

#ifndef __MY__
#define __MY__
//#define LOG(str) cout<
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"

#include "opencv2/nonfree/nonfree.hpp"
#include "opencv2/opencv.hpp"
#include "opencv2/stitching/stitcher.hpp"

#ifdef HAVE_OPENCV_GPU
#include "opencv2/gpu/gpu.hpp"
#endif
using namespace cv;
using namespace cv::detail;
//using  detail::ImageFeatures;

using namespace std;

namespace my_namespace{


struct  my_CameraParams
{

	my_CameraParams();
	my_CameraParams(const my_CameraParams& other);
	const my_CameraParams& operator =(const my_CameraParams& other);
	Mat K() const;

	double focal; // Focal length
	double aspect; // Aspect ratio
	double ppx; // Principal point X
	double ppy; // Principal point Y
	Mat R; // Rotation
	Mat t; // Translation

};


struct   myImageFeatures
{

    int img_idx;
    Size img_size;
    std::vector keypoints;
    Mat descriptors;

};

vector leaveBiggestComponent(vector &features,  vector &pairwise_matches,
								  float conf_threshold);
void waveCorrect(vector &rmats, WaveCorrectKind kind);

class CV_EXPORTS my_FeaturesFinder
{

public:
    virtual ~my_FeaturesFinder() {

}
	void operator ()(const Mat &image, /*detail::ImageFeatures*/myImageFeatures &features);
    void operator ()(const Mat &image, myImageFeatures &features, const std::vector &rois);
    virtual void collectGarbage() {

}

protected:
    virtual void find(const Mat &image, myImageFeatures &features) = 0;

};


class CV_EXPORTS my_SurfFeaturesFinder : public my_FeaturesFinder
{

public:
    my_SurfFeaturesFinder(double hess_thresh = 300., int num_octaves = 3, int num_layers = 4,
                       int num_octaves_descr = 4/*3*/, int num_layers_descr = 2/*4*/);

private:
    void find(const Mat &image, myImageFeatures &features);

    Ptr detector_;
    Ptr extractor_;
    Ptr surf;

};

class CV_EXPORTS my_OrbFeaturesFinder : public my_FeaturesFinder
{

public:
    my_OrbFeaturesFinder(Size _grid_size = Size(3,1), int nfeatures=1500, float scaleFactor=1.3f, int nlevels=5);

private:
    void find(const Mat &image, myImageFeatures &features);

    Ptr orb;
    Size grid_size;

};

//ƥ
class CV_EXPORTS my_FeaturesMatcher
{

public:
	virtual ~my_FeaturesMatcher() {

}

	void operator ()(const myImageFeatures &features1, const myImageFeatures &features2,
		MatchesInfo& matches_info) {
 match(features1, features2, matches_info); 
}

	void operator ()(const std::vector &features, std::vector &pairwise_matches,
		const cv::Mat &mask = cv::Mat());

	bool isThreadSafe() const {
 return is_thread_safe_; 
}

	virtual void collectGarbage() {

}

protected:
	my_FeaturesMatcher(bool is_thread_safe = false) : is_thread_safe_(is_thread_safe) {

}

	virtual void match(const myImageFeatures &features1, const myImageFeatures &features2,
		MatchesInfo& matches_info) = 0;

	bool is_thread_safe_;

};

class CV_EXPORTS my_BestOf2NearestMatcher : public my_FeaturesMatcher
{

public:
	my_BestOf2NearestMatcher(bool try_use_gpu = false, float match_conf = 0.3f, int num_matches_thresh1 = 40,
		int num_matches_thresh2 = 40);

	void collectGarbage();

protected:
	void match(const myImageFeatures &features1, const myImageFeatures &features2, MatchesInfo &matches_info);

	int num_matches_thresh1_;
	int num_matches_thresh2_;
	Ptr myimpl;

};

//bundle adjustment
class CV_EXPORTS my_Estimator
{

public:
	virtual ~my_Estimator() {

}

	void operator ()(const std::vector &features, const std::vector &pairwise_matches,
		std::vector &cameras)
	{
 estimate(features, pairwise_matches, cameras); 
}

protected:
	virtual void estimate(const std::vector &features, const std::vector &pairwise_matches,
		std::vector &cameras) = 0;

};

class CV_EXPORTS my_HomographyBasedEstimator : public my_Estimator
{

public:
	my_HomographyBasedEstimator(bool is_focals_estimated = false)
		: is_focals_estimated_(is_focals_estimated) {

}

private:
	void estimate(const std::vector &features, const std::vector &pairwise_matches,
		std::vector &cameras);

	bool is_focals_estimated_;

};
class CV_EXPORTS my_BundleAdjusterBase : public my_Estimator
{

public:
	const Mat refinementMask() const {
 return refinement_mask_.clone(); 
}
	void setRefinementMask(const Mat &mask)
	{

		CV_Assert(mask.type() == CV_8U && mask.size() == Size(3, 3));
		refinement_mask_ = mask.clone();
	
}

	double confThresh() const {
 return conf_thresh_; 
}
	void setConfThresh(double conf_thresh) {
 conf_thresh_ = conf_thresh; 
}

	CvTermCriteria termCriteria() {
 return term_criteria_; 
}
	void setTermCriteria(const CvTermCriteria& term_criteria) {
 term_criteria_ = term_criteria; 
}

protected:
	my_BundleAdjusterBase(int num_params_per_cam, int num_errs_per_measurement)
		: num_params_per_cam_(num_params_per_cam),
		num_errs_per_measurement_(num_errs_per_measurement)
	{

		setRefinementMask(Mat::ones(3, 3, CV_8U));
		setConfThresh(1.);
		setTermCriteria(cvTermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 1000, DBL_EPSILON));
	
}

	// Runs bundle adjustment
	virtual void estimate(const std::vector &features,
		const std::vector &pairwise_matches,
		std::vector &cameras);

	virtual void setUpInitialCameraParams(const std::vector &cameras) = 0;
	virtual void obtainRefinedCameraParams(std::vector &cameras) const = 0;
	virtual void calcError(Mat &err) = 0;
	virtual void calcJacobian(Mat &jac,FileStorage *fs) = 0;

	// 3x3 8U mask, where 0 means don't refine respective parameter, != 0 means refine
	Mat refinement_mask_;

	int num_images_;
	int total_num_matches_;

	int num_params_per_cam_;
	int num_errs_per_measurement_;

	const myImageFeatures *features_;
	const MatchesInfo *pairwise_matches_;

	// Threshold to filter out poorly matched image pairs
	double conf_thresh_;

	//LevenbergCMarquardt algorithm termination criteria
	CvTermCriteria term_criteria_;

	// Camera parameters matrix (CV_64F)
	Mat cam_params_;

	// Connected images pairs
	std::vector > edges_;

};

class CV_EXPORTS my_BundleAdjusterRay : public my_BundleAdjusterBase
{

public:
	//my_BundleAdjusterRay() : my_BundleAdjusterBase(7, 2) {

}
	my_BundleAdjusterRay() : my_BundleAdjusterBase(4, 3) {

}

private:

	void setUpInitialCameraParams(const std::vector &cameras);
	void obtainRefinedCameraParams(std::vector &cameras) const;
	void calcError(Mat &err);
	void calcJacobian(Mat &jac,FileStorage *fs);

	double ztemp;
	Mat err1_, err2_;

};
class mydetector
{

public:
	mydetector(void);
	~mydetector(void);

};


}//my_namespace
#endif // __OPENCV_STITCHING_MATCHERS_HPP__
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 3

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
autostitch.aps17.46 kB28-02-13 07:50
autostitch.cpp1.53 kB05-11-13 09:50
autostitch.h39.00 B10-12-12 20:48
autostitch.rc1.34 kB10-12-12 20:48
autostitch.vcproj5.58 kB05-11-13 09:52
autostitch.vcproj.HUANG.shui.user1.37 kB09-06-13 09:26
autostitch.vcproj.lenovo-PC.lenovo.user1.38 kB15-12-12 21:35
autostitch.vcproj.SHUI.shui.user1.37 kB05-11-13 09:58
autostitch.vcproj.WIN-B5OD78NL8FV.Administrator.user1.39 kB25-07-13 08:10
autostitch.vcproj.WM-20120911FOZO.shui.user1.39 kB17-12-12 08:38
autostitch.vcproj.WM-20140502VVLE.Administrator.user1.39 kB09-05-14 15:37
confidence.txt90.59 kB25-07-13 10:02
confidence14da.txt6.31 kB25-06-13 18:51
confidence200.txt1.92 MB23-06-13 23:18
confidence5.txt1.37 kB24-06-13 14:02
autostitch.pch32.25 MB05-11-13 09:54
BuildLog.htm77.02 kB05-11-13 09:54
stdafx.obj999.54 kB05-11-13 09:54
vc90.idb315.00 kB05-11-13 09:54
vc90.pdb2.55 MB05-11-13 09:54
Jacbion.xml60.00 B25-07-13 18:23
match.txt4.73 kB25-07-13 10:02
match.xml108.03 kB25-07-13 10:02
match14da.txt1.61 kB25-06-13 19:01
match200.txt8.56 kB24-06-13 08:25
match5.txt212.00 B24-06-13 15:00
match_features.txt5.16 kB25-07-13 10:02
match_features01.txt4.85 kB24-06-13 21:36
match_features14da.txt360.76 kB25-06-13 18:51
mat_xml.xml30.00 kB21-06-13 10:17
MyCompile.cpp71.44 kB27-07-13 14:30
MyCompile.h3.08 kB25-06-13 21:38
mydetector.cpp49.80 kB05-11-13 09:54
mydetector.h8.91 kB15-07-13 19:14
precomp.h2.47 kB28-07-12 06:59
qian.xml48.31 kB25-07-13 18:23
ReadMe.txt1.63 kB10-12-12 20:48
Resource.h393.00 B10-12-12 20:48
result14.00 B97% 14-07-13
result.jpg2.23 MB09-07-13 19:35
result0.jpg2.54 MB30-05-13 11:05
result00.jpg680.30 kB31-05-13 20:12
result10.jpg56.18 kB31-05-13 14:29
result10_.jpg59.45 kB31-05-13 14:35
result14.jpg1.63 MB22-06-13 12:22
result141.jpg748.67 kB25-06-13 18:57
result18.jpg77.57 kB17-06-13 18:26
result19.jpg322.94 kB19-06-13 03:36
result2.jpg1.69 MB30-05-13 18:21
result21.jpg483.43 kB30-05-13 19:12
result26.jpg375.77 kB15-07-13 13:32
<result27>0.00 B96% 24-07-13
result27.jpg2.23 MB15-07-13 20:02
result30.jpg2.52 MB24-07-13 19:25
resultff.jpg28.84 kB31-05-13 14:40
resultguangsu.jpg402.75 kB21-06-13 10:17
resultmulti.jpg366.37 kB30-05-13 16:39
result冲投影.jpg298.42 kB21-06-13 11:05
stdafx.cpp215.00 B10-12-12 20:48
stdafx.h813.00 B10-12-12 20:48
targetver.h1.00 kB10-12-12 20:48
TestFuc.cpp847.00 B23-05-13 10:54
TestFuc.h248.00 B07-05-13 09:01
transform.xml60.00 B25-07-13 18:23
result.jpg598.37 kB24-05-13 08:22
Thumbs.db12.50 kB31-05-13 09:46
发大水.jpg294.10 kB24-05-13 21:51
没有强行赋值.jpg363.02 kB24-05-13 10:37
<重投影>0.00 B99% 24-05-13
autostitch.ncb17.58 MB09-05-14 15:37
autostitch.sln896.00 B10-12-12 20:48
autostitch.suo138.00 kB09-05-14 15:37
<autostitch.ilk>0.00 B27-07-13 14:30
confidence.txt5.91 kB13-07-13 10:22
Jacbion.xml60.00 B22-06-13 08:20
match.txt1.34 kB13-07-13 10:22
match.xml13.32 kB13-07-13 10:22
match_features.txt21.78 kB13-07-13 10:22
mat_xml.xml1.14 MB21-06-13 09:54
qian.xml13.34 kB22-06-13 08:20
result.jpg1.11 kB22-06-13 08:20
result5.jpg297.38 kB21-06-13 09:54
<transform.xml>0.00 B13-07-13 10:12
readme.txt192.00 B24-05-13 14:11
<Debug>0.00 B11-01-14 07:12
<拼接结果>0.00 B11-01-14 07:12
<autostitch>0.00 B11-01-14 07:12
<Debug>0.00 B11-01-14 07:12
<autostitch_0610>0.00 B09-05-14 15:35
...
Sponsored links

mydetector.h (34.39 MB)

Need 3 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D