128 if ((*this).size()!=4)
131 cv::Scalar color(255, 0, 0);
134 cv::line(image, (*
this)[0], (*
this)[1], color, lineWidth, cv::LINE_AA);
135 cv::line(image, (*
this)[1], (*
this)[2], color, lineWidth, cv::LINE_AA);
136 cv::line(image, (*
this)[2], (*
this)[3], color, lineWidth, cv::LINE_AA);
137 cv::line(image, (*
this)[3], (*
this)[0], color, lineWidth, cv::LINE_AA);
138 cv::rectangle(image, (*
this)[0]-cv::Point2f(2,2), (*
this)[0]+cv::Point2f(2,2), cv::Scalar(0,0,255), lineWidth, cv::LINE_AA);
139 cv::rectangle(image, (*
this)[1]-cv::Point2f(2,2), (*
this)[1]+cv::Point2f(2,2), cv::Scalar(0,255,0), lineWidth, cv::LINE_AA);
140 cv::rectangle(image, (*
this)[2]-cv::Point2f(2,2), (*
this)[2]+cv::Point2f(2,2), cv::Scalar(255,0,0), lineWidth, cv::LINE_AA);
143 sprintf(cad,
"id=%d",
id);
147 for (
int i = 0; i < 4; i++)
149 cent.x +=
static_cast<int>((*this)[i].x);
150 cent.y +=
static_cast<int>((*this)[i].y);
155 cv::putText(image, cad, cent, cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(255-color[0], 255-color[1], 255-color[2]), 2);
170 double modelview_matrix[16];
176 marker.glGetModelViewMatrix(modelview_matrix);
178 catch(std::exception&)
183 if(marker.size() == 4)
187 Vector3 pixelPosition(0.0,0.0,0.0);
188 for (
int j=0;j<4;j++)
190 pixelPosition.
x += marker[j].x;
191 pixelPosition.
y += marker[j].y;
194 pixelPosition.
z = sqrt(pow((marker[1].x - marker[0].x),2) + pow((marker[1].y - marker[0].y),2));
195 pixelPosition.
z += sqrt(pow((marker[2].x - marker[1].x),2) + pow((marker[2].y - marker[1].y),2));
196 pixelPosition.
z += sqrt(pow((marker[3].x - marker[2].x),2) + pow((marker[3].y - marker[2].y),2));
197 pixelPosition.
z += sqrt(pow((marker[0].x - marker[3].x),2) + pow((marker[0].y - marker[3].y),2));
199 pixelPosition.
x/=4.0f;
200 pixelPosition.
y/=4.0f;
201 pixelPosition.
z/=4.0f;
208 SetPosition(
Vector3(
static_cast<float>(reverse ? -modelview_matrix[12] : modelview_matrix[12]) + offset.
x,
static_cast<float>(modelview_matrix[13]) + offset.
y,
static_cast<float>(modelview_matrix[14]) + offset.
z));
310 cv::Mat R(3, 3, CV_32F);
311 cv::Rodrigues(rotation, R);
313 cv::Mat RX = cv::Mat::eye(3, 3, CV_32F);
314 const float angleRad = 3.14159265359f / 2.f;
315 RX.at<
float>(1, 1) = cos(angleRad);
316 RX.at<
float>(1, 2) = -sin(angleRad);
317 RX.at<
float>(2, 1) = sin(angleRad);
318 RX.at<
float>(2, 2) = cos(angleRad);
322 cv::Rodrigues(R, rotation);