Project

General

Profile

BitmapToolkit Scol plugin
ArCameraParam.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
25#ifndef __BTK_ARCAMERAPARAM_H__
26#define __BTK_ARCAMERAPARAM_H__
27
28#include "Prerequisites.h"
29#include <aruco.h>
30#include <AR/ar.h>
31
32
34{
35 ArImuData() : m_gry(Vector3(0.0, 0.0, 0.0)), m_acc(Vector3(0.0, 0.0, 0.0)), m_delta(0.0) {};
36 ArImuData(Vector3 _gry, Vector3 _acc, double delta) : m_gry(Vector3(_gry)), m_acc(Vector3(_acc)), m_delta(delta) {};
39 double m_delta;
40};
41
43{
44 // Variable
45 public :
46 protected:
47
48 private:
49 cv::Size bitmapSize;
50 cv::Point2f clipping;
51
52 //Functions
53 public :
55 ArCameraParam(int width, int height, float nearclip, float farclip, std::string yamlfile);
56 ArCameraParam(int width, int height, float nearclip, float farclip, Vector2 &flength, Vector2 &center);
58
60
61 aruco::CameraParameters GetCameraParameter();
62
63 void SetCameraParameter(std::string yamlfile);
64
65 cv::Size GetBitmapSize();
66 void SetBitmapSize(int width, int height);
67
68 cv::Point2f GetClipping();
69 void SetClipping(float nearclip, float farclip);
70
71 void GetProjectionMatrix(double m_proj[16], cv::Size screensize);
72
73 void SetCameraQuat(BtQuaternion quat);
75
76 void AddCameraImu(Vector3 gyro, Vector3 accel, double delta);
77 std::vector<ArImuData> GetCameraImu() const;
78 void ResetCameraImu();
79
81 void SetCameraOffset(Vector3 offset);
82
83 protected:
85 std::vector<ArImuData> mImuData;
87
88 public:
89 aruco::CameraParameters camParam;
90};
91
93{
94public:
95 LASTDATA() : reversedBitmap(false), timeStamp(0.0), delta(0.0) {};
96
97 LASTDATA(const LASTDATA &CI)
98 {
101 timeStamp = CI.timeStamp;
102 delta = CI.delta;
103
104 if (!CI.image.empty())
105 CI.image.copyTo(image);
106
107 if (!CI.gray.empty())
108 CI.gray.copyTo(gray);
109 }
110
111 LASTDATA(cv::Mat &frm, ArCameraParam* camparam, bool reverse, double _timestamp, double _delta)
112 {
113 reversedBitmap = reverse;
114 timeStamp = _timestamp;
115 delta = _delta;
116 arCamParam = ArCameraParam(*camparam);
117
118 try
119 {
120 if (frm.channels() != 1)
121 cv::cvtColor(frm, gray, cv::COLOR_BGR2GRAY);
122 else
123 frm.copyTo(gray);
124
125 frm.copyTo(image);
126 }
127 catch(std::exception &)
128 {
129 // bad bitmap format
130 }
131 };
132
134 {
135 image.release();
136 gray.release();
137 };
138
140 double timeStamp;
141 double delta;
143 cv::Mat image;
144 cv::Mat gray;
145};
146
147
148#endif
cv::Point2f GetClipping()
void SetCameraOffset(Vector3 offset)
void SetCameraQuat(BtQuaternion quat)
BtQuaternion GetCameraQuat()
void GetProjectionMatrix(double m_proj[16], cv::Size screensize)
void AddCameraImu(Vector3 gyro, Vector3 accel, double delta)
void SetClipping(float nearclip, float farclip)
std::vector< ArImuData > GetCameraImu() const
Vector3 GetCameraOffset()
void SetBitmapSize(int width, int height)
cv::Size GetBitmapSize()
BtQuaternion mCamQuat
void SetCameraParameter(std::string yamlfile)
std::vector< ArImuData > mImuData
aruco::CameraParameters GetCameraParameter()
aruco::CameraParameters camParam
Vector3 mCamOffset
ArCameraParam arCamParam
cv::Mat image
cv::Mat gray
LASTDATA(const LASTDATA &CI)
bool reversedBitmap
double delta
LASTDATA(cv::Mat &frm, ArCameraParam *camparam, bool reverse, double _timestamp, double _delta)
double timeStamp
Vector3 m_gry
ArImuData(Vector3 _gry, Vector3 _acc, double delta)
Vector3 m_acc
double m_delta