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

📄 calibrationhelper.h

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

//////////////////////////////////////////////////////////////
// Definition of CalibrationHelper class - manages the
// camera-calibration process.
//


#ifndef __MAVIS_CAMERA_CALIBRATIONHELPER
#define __MAVIS_CAMERA_CALIBRATIONHELPER

#include <windows.h>
#include <string>
#include "../mavistypes.h"

// Strings for ini file
#define CAMERA_SECTION   "camera"
#define HOMEBASE_SECTION "HomeBase"


class Mavis;
class Homebase;

using namespace std;

class CalibrationHelper
{
public:
	const char * getMsg() { return msg.c_str(); }

	// do the next step in the calibration process
	bool nextStep();

	bool hasNextStep() { return calibStep < CALIBRATION_FINISHED; }

	// for testing
	double getCameraZ() { return cameraZ; }
	double getCameraY() { return cameraY; }
	double getWhiteDiam() { return whiteDiam; }

protected:
	friend class Mavis;

	// Constructor and Destructor
	CalibrationHelper(Mavis *);
	~CalibrationHelper();

	void stop();

private:
	bool       bStop;
	bool       bThreadFinished;
	Mavis *    pMv;
	HANDLE     hVideoThread;
	BYTE *     pBmpBuffer;
	Homebase * pHomeBase;

	string    msg;
	static const string INITIAL_EST_MSG;
	static const string PIVOT_CENTER_MSG;
	static const string TOP_CTR_MSG;

	double    cameraZ;   // camera height, mm
	double    cameraY;   // fwd displacement from center, mm
	double    whiteDiam; // diameter of circle's white region, mm
	double    f;         // camera focal length
	//double    tiltAngle; // camera's tiltAngle angle
	double    tiltAngle;

	double    fTop;
	double    fBottom;

	int       imgH;
	int       imgW;
	int       crossHairsX;
	int       crossHairsY;

	// The current calibration phase - acts as a state variable.
	int       calibStep;

	// Calibration phases
	static const int INITIAL_EST_STEP;
	static const int PIVOT_CENTER_STEP;
	static const int TOP_CTR_STEP;
	static const int BOTTOM_CTR_STEP;
	static const int APPROACH_STEP;
	static const int CALIBRATION_FINISHED;
	static const int ERROR_EXIT;

	//////////////////
	//  FUNCTION: threadproc()
	//
	//  PURPOSE:  Run a video-loop thread. Apparently, the thread's method needs
	//            to be outside an instantiated object. At least, I wasn't able
	//            to get this working with an instance method.
	//
	//  INPUTS:   lpThreadData - pointer to a CalibrationHelper object.
	//
	static DWORD WINAPI threadproc( LPVOID lpThreadData );

	void runVideo();

	void prepareNextStep();

	//////////////////
	//  FUNCTION: addCrosshairs()
	//
	//  PURPOSE:  Places a horizontal and a vertical line through
	//            the center of the image.
	//
	void addCrosshairs();


	//////////////////
	//  FUNCTION: DrawLine()
	//
	//  PURPOSE:  Adds a line to the frame image.
	//
	void DrawLine(int x1, int y1, int x2, int y2, int rgb);

	void estimateFocalLenAndAngle(ObjSighting_t *, bool recomputeF=true);

	double reestimateFocalLen(ObjSighting_t *, double theta);

	// Hide copy constructor and assignment operator
	CalibrationHelper(const CalibrationHelper &);
	CalibrationHelper & CalibrationHelper::operator=(const CalibrationHelper &);
};


#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 + -