hor_search.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <filters/hor_search.h>
00026
00027 #include <fvutils/color/yuv.h>
00028
00029 #include <cstddef>
00030 #include <cstring>
00031
00032 namespace firevision {
00033 #if 0
00034 }
00035 #endif
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 FilterHSearch::FilterHSearch(ColorModel *cm, color_t what)
00050 : Filter("FilterHSearch")
00051 {
00052 this->cm = cm;
00053 this->what = what;
00054 }
00055
00056
00057 void
00058 FilterHSearch::apply()
00059 {
00060 register unsigned int h = 0;
00061 register unsigned int w = 0;
00062
00063
00064 register unsigned char *yp = src[0] + (src_roi[0]->start.y * src_roi[0]->line_step) + (src_roi[0]->start.x * src_roi[0]->pixel_step);
00065
00066 register unsigned char *up = YUV422_PLANAR_U_PLANE(src[0], src_roi[0]->image_width, src_roi[0]->image_height)
00067 + ((src_roi[0]->start.y * src_roi[0]->line_step) / 2 + (src_roi[0]->start.x * src_roi[0]->pixel_step) / 2) ;
00068
00069 register unsigned char *vp = YUV422_PLANAR_V_PLANE(src[0], src_roi[0]->image_width, src_roi[0]->image_height)
00070 + ((src_roi[0]->start.y * src_roi[0]->line_step) / 2 + (src_roi[0]->start.x * src_roi[0]->pixel_step) / 2);
00071
00072
00073 register unsigned char *dyp = dst + (dst_roi->start.y * dst_roi->line_step) + (dst_roi->start.x * dst_roi->pixel_step);
00074
00075
00076 unsigned char *lyp = yp;
00077 unsigned char *lup = up;
00078 unsigned char *lvp = vp;
00079 unsigned char *ldyp = dyp;
00080
00081
00082 unsigned int left;
00083 unsigned int right;
00084 bool flag;
00085
00086 for (h = 0; (h < src_roi[0]->height) && (h < dst_roi->height); ++h) {
00087 flag = false;
00088 left = right = 0;
00089 for (w = 0; (w < src_roi[0]->width) && (w < dst_roi->width); ++w) {
00090 if ( (cm->determine(*yp++, *up, *vp) == what) ) {
00091 right = w;
00092 flag = true;
00093 } else {
00094 left = flag?left:w;
00095 }
00096 if ( (cm->determine(*yp++, *up++, *vp++) == what) ) {
00097 right = ++w;
00098 flag = true;
00099 } else {
00100 ++w;
00101 left = flag?left:w;
00102 }
00103 }
00104
00105
00106 memset(ldyp, 0, dst_roi->width);
00107
00108
00109
00110
00111 if (left != 0 && left < dst_roi->width) ldyp[left] = 255;
00112 if (right != 0 && right < dst_roi->width) ldyp[right] = 255;
00113
00114 lyp += src_roi[0]->line_step;
00115 lup += src_roi[0]->line_step / 2;
00116 lvp += src_roi[0]->line_step / 2;
00117 ldyp += dst_roi->line_step;
00118 yp = lyp;
00119 up = lup;
00120 vp = lvp;
00121 dyp = ldyp;
00122 }
00123
00124 }
00125
00126 }