📄 camera.h
字号:
// Camera.h - by Robin Hewitt, 2005-2005
// The initial version of this class was kindly
// contributed by Ed LeBouthillier, 2004
// http://home.earthlink.net/~apendragn
// This is free software. See license at the bottom
// of this file for terms of use.
//
//////////////////////////////////////////////////////////////
// Header for the Camera class
//
// Contains camera parameters such as tilt angle and focal length.
//
// Todo: There's a method called Camera::screen2world() that returns a
// WorldCoord class given an (x,y) image coordinate. This is a misleading
// name. The method assumes the object is on the floor. Otherwise, it would
// only be able to constrain it to be on a line. We put this into the initial
// version because we were getting ready to enter a contest and needed to
// locate homebase. It needs to be changed.
#ifndef __MAVIS_CAMERA_CAMERA
#define __MAVIS_CAMERA_CAMERA
#include "WorldCoord.h"
#include "Mavis.h"
// when computing a world coordinate or a scale factor from a pixel value,
// an additional constraint is needed.
enum LocConstraint_t {
HEIGHT_CONSTRAINT, // distance above floor in mm
FWD_DISTANCE_CONSTRAINT // distance along travel path, from robot's center
};
class Mavis;
class Pixel;
class Camera
{
public:
double getFocalLen() { return f; }
void setFocalLen(double f);
double getTiltAngle() { return tiltAngle; }
void setTiltAngle(double theta);
int getIsCalibrated() { return isCalibrated; }
void setIsCalibrated(int newValue=1);
// Computes a scale factor, f/Z (pixels/mm), at a pixel, given a location
// constraint. If the scaling can't be computed, it returns false;
bool getScale(
Pixel_t *,
double constraint,
LocConstraint_t,
double * pScale);
// Retrieves camera configuration data
void getCameraData(CameraData_t *);
// Convert a Coordinate in screen coordinates to world coordinates
WorldCoord screen2world(int x, int y);
protected:
friend class Mavis;
// Constructor and Destructor
Camera(Mavis * pMavis);
~Camera();
private:
double camera_X; // Left/Right position of camera from origin (mm)
double fwdPosition; // forward/reverse position of camera from origin (mm)
double height; // height of camera above ground (mm)
double f; // focal length (pixels)
int isCalibrated;
double imgHeight;
double imgWidth;
double halfImgHeight; // 1/2 the image height
double halfImgWidth; // 1/2 the image width
double tiltAngle; // Camera's tilt angle. Positive is looking up up.
double sinTiltAngle;
double cosTiltAngle;
Mavis * pMavis;
};
#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, Ed LeBouthillier (http://home.earthlink.net/~apendragn)
// 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 + -