94 if (avgChannels < im->nChannels) {
115 for (
int t=0; t<
nbTri;t++) {
117 for (
int i=0; i<3; i++) {
128 if (nx<1 || ny<1)
return false;
134 vertices = cvCreateMat(3, (nx+1)*(ny+1), CV_32FC1);
136 for (
int y=0; y<(ny+1); ++y)
137 for (
int x=0; x<(nx+1); ++x) {
138 CV_MAT_ELEM(*
vertices,
float, 0, y*(nx+1)+x) = float(x)/float(nx);
139 CV_MAT_ELEM(*
vertices,
float, 1, y*(nx+1)+x) = float(y)/float(ny);
140 CV_MAT_ELEM(*
vertices,
float, 2, y*(nx+1)+x) = 1;
147 for (
int y=0; y<
ny; ++y)
148 for (
int x=0; x<
nx; ++x) {
150 tri[1] = y*(nx+1)+x+1;
151 tri[2] = (y+1)*(nx+1)+x;
153 tri[0] = y*(nx+1)+x+1;
154 tri[1] = (y+1)*(nx+1)+x+1;
155 tri[2] = (y+1)*(nx+1)+x;
160 if (!H.
estimate(0, 0, corners[0][0], corners[0][1],
161 1, 0, corners[1][0], corners[1][1],
162 1, 1, corners[2][0], corners[2][1],
163 0, 1, corners[3][0], corners[3][1]))
167 CvMat r1,r2,r3, d1, d2;
189 for (
int t=0; t<
nbTri;t++) {
191 for (
int i=0; i<3; i++) {
195 cvLine(im,
cvPoint(pts[0][0], pts[0][1]),
cvPoint(pts[1][0], pts[1][1]), cvScalarAll(255), 1,4,0);
196 cvLine(im,
cvPoint(pts[1][0], pts[1][1]),
cvPoint(pts[2][0], pts[2][1]), cvScalarAll(255), 1,4,0);
197 cvLine(im,
cvPoint(pts[2][0], pts[2][1]),
cvPoint(pts[0][0], pts[0][1]), cvScalarAll(255), 1,4,0);
203 for (
int t=0; t<
nbTri;t++) {
205 for (
int i=0; i<3; i++) {
212 col = CV_RGB(c[0], c[1], c[2]);
214 col = cvScalarAll(
avg[t]);
216 cvFillConvexPoly(im, pts, 3, col);
230 Hdr *hdr = (
Hdr *) buffer;
242 const Hdr *hdr = (
const Hdr *) buffer;
255 printf(
"problem!\n");
258 memcpy(
avg, buffer +
sizeof(
Hdr),
nbTri*avgChannels*
sizeof(
float));
271 if (
avg==0)
return false;
274 const float ones[3] = {1,1,1};
275 const float zeroes[3] = {0,0,0};
276 const float *scale = (_scale ? _scale : ones);
277 const float *shift = (_shift ? _shift : zeroes);
278 vector<float> values[3];
280 values[0].reserve(
nbTri);
281 values[1].reserve(
nbTri);
282 values[2].reserve(
nbTri);
284 for (
int i=0; i<
nbTri; i++) {
286 float v =
avg[i*avgChannels+c];
287 float rv = ref.
avg[i*avgChannels+c];
288 if (v>= 5 && v<=250 && rv >= 5 && rv <= 250) {
289 values[c].push_back((scale[c]*v+shift[c])/rv);
294 if (values[i].size()>0) {
295 val[i] = values[i][values[i].size()/2];