⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subpixeledge.h

📁 机器人程序
💻 H
字号:
// SubpixelEdge.h - by Robin Hewitt, 2004
// http://www.robinhewitt.com/mavis
// This is free software. See license at the bottom
// of this file for details.
//

//////////////////////////////////////////////////////////////
// Header file for the SubpixelEdge classes.
//
// These are currently a special-purpose set of helper classes that
// are only used for camera calibration. They look only at one
// component of gradient (x or y), and do a subpixel edge location
// just for that component. They could be generalized to do a
// 2-component edge location, but that hasn't been needed. Generalizing
// would probably entail some design changes.
//
// todo: develop this into a general-purpose imageUtil class.
//

#ifndef __OBJREC_SUBPIXELEDGE
#define __OBJREC_SUBPIXELEDGE

#include "MVLib.h"

class Region;


//////////////////////////////////////////////////////////////
//  Class: SubpixelEdge
//
class SubpixelEdge
{
public:
	static const int MAX;
	static const int MIN;
	static const int MAX_ABSVAL;
	static const int MIN_ABSVAL;

	virtual ~SubpixelEdge();

	int getIndepLo() {return indepVarLo;}
	int getIndepHi() {return indepVarLo + nPts - 1;}

	double getDepMin()  {return edgeMin;}
	double getDepMax()  {return edgeMax;}

	double getDepVarAtValue(int val) {return subpixelLoc[val-indepVarLo];}
	double getDepVarAtIndex(int i) {return subpixelLoc[i];}

	void offsetIndepVar(int offset) {indepVarLo += offset;}
	void offsetDepVar(double offset);

	int getNPoints();

protected:
	double * subpixelLoc;
	int indepVarLo;
	double edgeMin, edgeMax;
	int nPts;

	// constructor (only avail to subclasses)
	SubpixelEdge(
		int * depVal,    // values of dependent variable
		int indepMin,    // min value of independent variable
		int indepMax,    // max value of independent variable
		int * indepVal,  // values of independent variable
		int nPx,
		MVImg<int> * pImg,
		int (*imgVal)(MVImg<int> *,int,int),
		int cmpType
	);


	// comparison methods
	static bool isGT(int i1, int i2);
	static bool isLT(int i1, int i2);
	static bool absValIsGT(int i1, int i2);
	static bool absValIsLT(int i1, int i2);
};



//////////////////////////////////////////////////////////////
//  Class: YofXSubpixelEdge
//
class YofXSubpixelEdge : public SubpixelEdge
{
public:
	YofXSubpixelEdge(Region *pRegion, MVImg<int> * pImg, int cmpType=SubpixelEdge::MAX_ABSVAL);

	int getXLo()  { return getIndepLo(); }
	int getXHi()  { return getIndepHi(); }
	double getYMin() { return getDepMin(); }
	double getYMax() { return getDepMax(); }

	double getYAtX(int x)     { return getDepVarAtValue(x); }
	double getYAtIndex(int i) { return getDepVarAtIndex(i); }

	void offsetX(int offset) { offsetIndepVar(offset); }
	void offsetY(double offset) { offsetDepVar(offset); }

protected:
	// method that returns an image value - for the Subpixel constructor method
	static int imgVal(MVImg<int> *, int x, int y);


	// Protect copy constructor and assignment operator until implemented
	YofXSubpixelEdge(const YofXSubpixelEdge &);
	YofXSubpixelEdge & YofXSubpixelEdge::operator=(const YofXSubpixelEdge &);
};



//////////////////////////////////////////////////////////////
//  Class: XofYSubpixelEdge
//
class XofYSubpixelEdge : public SubpixelEdge
{
public:
	XofYSubpixelEdge(Region *pRegion, MVImg<int> * pImg, int cmpType=SubpixelEdge::MAX_ABSVAL);

	int getYLo()  { return getIndepLo(); }
	int getYHi()  { return getIndepHi(); }
	double getXMin() { return getDepMin(); }
	double getXMax() { return getDepMax(); }

	double getXatY(int x)     { return getDepVarAtValue(x); }
	double getXAtIndex(int i) { return getDepVarAtIndex(i); }

	void offsetY(int offset) { offsetIndepVar(offset); }
	void offsetX(double offset) { offsetDepVar(offset); }

protected:
	// method that returns an image value - for the Subpixel constructor method
	static int imgVal(MVImg<int> * pImg, int y, int x);

	// Protect copy constructor and assignment operator until implemented
	XofYSubpixelEdge(const XofYSubpixelEdge &);
	XofYSubpixelEdge & XofYSubpixelEdge::operator=(const XofYSubpixelEdge &);
};

#endif

///////////////////////////////////////////////////////////////////////////////////////
// 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.
//
//
//                        Mavis License Agreement
//
// Copyright (c) 2004-2005, Robin Hewitt (http://www.robin-hewitt.com).
// 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:
//
//   * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//
//   * Redistributions 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.
//
// This software is provided "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 authors 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.
///////////////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -