27 #include <opencv2/core/core.hpp>
28 #include <opencv2/imgproc/imgproc.hpp>
31 #include <linux/videodev2.h>
86 itsSaliency = addSubComponent<Saliency>(
"saliency");
87 itsKF = addSubComponent<Kalman2D>(
"kalman");
98 inimg.
require(
"input",
w,
h, V4L2_PIX_FMT_YUYV);
107 unsigned int const ow = outimg.
width, oh = outimg.height;
108 outimg.require(
"output", ow, oh, V4L2_PIX_FMT_GREY);
122 int const smadj = smlev > 0 ? (1 << (smlev-1)) : 0;
123 unsigned int const dmx = (mx << smlev) + smadj;
124 unsigned int const dmy = (my << smlev) + smadj;
128 float kfxraw, kfyraw;
itsKF->get(kfxraw, kfyraw, 1.0
F);
135 unsigned int const gistonlyw = 72;
unsigned int const gistsize =
itsSaliency->gist_size;
136 unsigned int gisth = (gistsize + ow - 1) / ow;
138 if (
false == ( (ow == mapw && oh == maph) ||
139 (ow == mapw * 6 && oh == maph) ||
140 (ow == gistonlyw && oh == gistsize / gistonlyw) ||
141 (ow == mapw && oh == maph + (gistsize + mapw - 1) / mapw) ||
142 (ow == mapw * 6 && oh == maph + (gistsize + mapw*6 - 1) / (mapw*6)) ) )
143 LFATAL(
"Incorrect output size. With current saliency parameters, valid sizes are: " <<
144 mapw <<
'x' << maph <<
" (saliency map only), " <<
145 mapw * 6 <<
'x' << maph <<
" (saliency map + feature maps), " <<
146 gistonlyw <<
'x' << gistsize / gistonlyw <<
" (gist only), " <<
147 mapw <<
'x' << maph + (gistsize + mapw - 1) / mapw <<
" (saliency map + gist), " <<
148 mapw * 6 <<
'x' << maph + (gistsize + mapw*6 - 1) / (mapw*6) <<
" (saliency + feature maps + gist).");
151 unsigned int offset = 0;
152 if (oh == maph || oh == maph + gisth)
166 if (oh == gisth || oh == maph + gisth)
168 unsigned char * d = outimg.pixelsw<
unsigned char>();
if (oh == maph + gisth) d += ow * maph;
172 int const rem = ow * gisth - gistsize;
173 if (rem > 0) memset(d + gistsize, 0, rem);
186 unsigned int const ow = outimg.
width, oh = outimg.
height;
188 if (fh > oh)
LFATAL(
"Map would extend past output image bottom");
189 if (fw + dx > ow)
LFATAL(
"Map would extend past output image width");
191 unsigned int const stride = ow - fw;
195 for (
unsigned int j = 0; j < fh; ++j)
197 for (
unsigned int i = 0; i < fw; ++i)
199 intg32 v = (*s++) >> bitshift;
if (v > 255) v = 255;
200 *d++ = (
unsigned char)(v);