{"id":165677,"date":"2013-01-13T22:53:02","date_gmt":"2013-01-13T18:53:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=165677"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=165677","title":{"rendered":"<span class=\"post_title\">ViBe \u2014 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f \u0444\u043e\u043d\u0430<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<h5>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/h5>\n<p>  \u041f\u0430\u0440\u0443 \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434, \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0438 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435\u043c \u0434\u0432\u0438\u0436\u0443\u0449\u0438\u0445\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u043d\u0435\u043c\u0430\u043b\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f \u0444\u043e\u043d\u0430, \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0442\u043e\u0442, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u043f\u043e\u0439\u0434\u0435\u0442 \u0440\u0435\u0447\u044c. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0435\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u2014 \u043a\u0443\u0447\u0430 \u043f\u0430\u0442\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u043d \u0437\u0430\u0449\u0438\u0449\u0435\u043d. \u041d\u043e \u043e\u0434\u043d\u043e \u0438\u0437 \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u044b\u0445 \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432 \u2014 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043f\u043e\u0434 Linux, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0435\u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445. \u041d\u0430 <a href=\"http:\/\/www2.ulg.ac.be\/telecom\/research\/vibe\/\">\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435<\/a> \u0441 \u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u044d\u0442\u0443 \u0441\u0430\u043c\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0430 \u0442\u0430\u043a\u0436\u0435 demo-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u043e\u0434 Windows \u0438 Android, \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043f\u0430\u0442\u0435\u043d\u0442\u044b (\u0433\u0434\u0435 \u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430) \u0438 \u043f\u0440\u043e\u0447\u0443\u044e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/241\/f47\/6ce\/241f476ce4f5066e3dcbebe14162b22c.jpg\" alt=\"image\"\/><\/p>\n<h5>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430<\/h5>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0435\u0441\u0442\u044c \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0414\u043b\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0433\u0440\u0430\u0434\u0430\u0446\u0438\u044f\u0445 \u0441\u0435\u0440\u043e\u0433\u043e:  <\/p>\n<pre><code class=\"cpp\">#include &quot;vibe-background.h&quot;      int main(int argc, char **argv){      \/\/ \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c ViBe      vibeModel_t *model = libvibeModelNew();       \/\/ stride - \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442, \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0435 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f       uint8_t *image_data = acquire_image(stream);      int32_t width = get_image_width(stream);      int32_t height = get_image_height(stream);      int32_t stride = get_image_stride(stream);       \/\/ \u041c\u0430\u0442\u0440\u0438\u0446\u0430 \u0434\u043b\u044f \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445      uint8_t *segmentation_map = malloc(stride * height);         \/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0435\u0440\u0432\u044b\u043c \u043a\u0430\u0434\u0440\u043e\u043c      libvibeModelAllocInit_8u_C1R(model, image_data, width, height, stride);         \/\/ \u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u0430\u0434\u0440\u044b      \/\/ \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f - \u0432 segmentation_map      while(!finished(stream)){         image_data = acquire_image(stream);         libvibeModelUpdate_8u_C1R(model, image_data, segmentation_map);      }       \/\/ \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u044c      libvibeModelFree(model);   } <\/code><\/pre>\n<h5>\u0415\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u0438<\/h5>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435. \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438, \u043d\u043e, \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438\u0437 \u043f\u0430\u0442\u0435\u043d\u0442\u0430, h \u2014 \u0444\u0430\u0439\u043b\u0430 \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0434\u043b\u044f \u0435\u0433\u043e \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0430\u0440\u044b \u043d\u043e\u0447\u0435\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043b\u0438\u0442\u0440\u043e\u0432 \u043a\u043e\u0444\u0435.<br \/>  \u0418\u0442\u0430\u043a, \u043a\u0430\u043a \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>  \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 vibeModel_t:  <\/p>\n<pre><code class=\"cpp\">typedef struct {          u8b  *samples;         u32b numberOfSamples;         u32b sizeOfSample; } pixel;  typedef struct {    pixel *pixels;    u32b width;    u32b height;    u32b stride;    u32b numberOfSamples;    u32b matchingThreshold;    u32b matchingNumber;    u32b updateFactor;    }  vibeModel;  typedef vibeModel vibeModel_t; <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0437\u0430\u0447\u0435\u043c \u2014 \u0431\u0443\u0434\u0435\u0442 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0438\u0437 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<br \/>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c, \u0437\u0430\u0434\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c random.<\/p>\n<pre><code class=\"cpp\">vibeModel *libvibeModelNew() {         vibeModel *model = (vibeModel*)calloc(1,sizeof(vibeModel));         if (model)         {                 model-&gt;numberOfSamples    = 20;                 model-&gt;matchingThreshold  = 20;                 model-&gt;matchingNumber     = 2;                 model-&gt;updateFactor       = 16;         }         u32b seed = time(0);         srand(seed);         return model; } <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u043a\u0443\u0447\u0443 \u043a\u043e\u0434\u0430, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f  <\/p>\n<pre><code class=\"cpp\">u32b getRandPixel(const u8b *image_data, const u32b width, const u32b height, const u32b stride, const u32b x, const u32b y); <\/code><\/pre>\n<p>  \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e\u0441\u044f \u0440\u044f\u0434\u043e\u043c \u0441 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u043c [x.y]. \u0422\u043e\u0433\u0434\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">s32b libvibeModelAllocInit_8u_C1R(vibeModel *model, const u8b *image_data, const u32b width, const u32b height, const u32b stride) {         if (!model || !image_data || !width || !height || !stride || (stride&lt;width)) return 1; \t\/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u043a\u0430\u0434\u0440\u0430         model-&gt;width  = width;         model-&gt;height = height;         model-&gt;stride = stride; \t\/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f          model-&gt;pixels = 0;         model-&gt;pixels = (pixel*)calloc(model-&gt;width*model-&gt;height, sizeof(pixel)); \tif (!model-&gt;pixels) return 1;  \t\/\/ \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u043e\u0434 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u044d\u043c\u043f\u043b\u043e\u0432.         for (u32b i=0; i &lt; model-&gt;width*model-&gt;height; i++)         {                 model-&gt;pixels[i].numberOfSamples=model-&gt;numberOfSamples;                 model-&gt;pixels[i].sizeOfSample = 1;                 model-&gt;pixels[i].samples = 0;                 model-&gt;pixels[i].samples = (u8b*)calloc(model-&gt;numberOfSamples,sizeof(u8b));                 if (!model-&gt;pixels[i].samples) return 1;         }  \t\/\/ \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438. \t\/\/ \u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u044d\u043c\u043f\u043b\u044b. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f, \t\/\/  \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445.         u32b n=0;         for (u32b j=0; j &lt; model-&gt;height; j++)         {                 for (u32b i=0; i &lt; model-&gt;width; i++)                 {                         model-&gt;pixels[n].samples[0] = image_data[i+j*stride];                         for (u32b k=1; k &lt; model-&gt;numberOfSamples; k++)                                 model-&gt;pixels[n].samples[k] = getRandPixel(image_data, width, height, stride, i, j);                         n++;                 }         }         return 0; } <\/code><\/pre>\n<p>  \u041c\u043e\u0434\u0435\u043b\u044c \u0433\u043e\u0442\u043e\u0432\u0430. \u0424\u0443\u043d\u043a\u0446\u0438\u044f libvibeModelAllocInit_8u_C3R \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043f\u043e\u0445\u043e\u0436\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0441\u044d\u043c\u043f\u043b\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435 \u043e\u0434\u0438\u043d \u0431\u0430\u0439\u0442, \u0430 \u0442\u0440\u0438.<br \/>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0441\u0430\u043c\u043e \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u0444\u043e\u043d\u0430 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u043c\u043e\u0434\u0435\u043b\u0438. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u0444\u043e\u043d\u0430, \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043e\u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">\/\/ pix_data - \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \/\/ pixel - \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0438\u0437 vibeModel s32b comparePixel(u8b pix_data, pixel *pixel, u32b matchingThreshold, u32b matchingNumber) {                 u32b matchingCounter=0; \t\/\/ \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0441\u044d\u043c\u043f\u043b\u0430\u043c\u0438         for (u32b i=0; i&lt;pixel-&gt;numberOfSamples; i++)         {                                 if (abs((s32b)pix_data-(s32b)pixel-&gt;samples[i]) &lt; matchingThreshold)                 { \t\t\t\/\/ \u0415\u0441\u043b\u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u044d\u043c\u043f\u043b\u043e\u0432 MatchingNumber, \t\t\t\/\/ \u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043d\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0438\u0439 \u043e\u0442 \u0444\u043e\u043d\u0430                         matchingCounter++;                         if (matchingCounter &gt;= matchingNumber)                                 return 1;                 }         }         return 0; } <\/code><\/pre>\n<p>  \u0415\u0449\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f  <\/p>\n<pre><code class=\"cpp\">updateModel(vibeModel *model, u8b pix_data, u32b width, u32b height, u32b stride, u32b x, u32b y); <\/code><\/pre>\n<p>  \u043a\u043e\u0442\u043e\u0440\u0430\u044f, \u043a\u0430\u043a \u0438 getRandPixel(&#8230;), \u0434\u043b\u0438\u043d\u043d\u0430\u044f \u0438 \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u0442\u0430\u043a \u0447\u0442\u043e \u043a\u043e\u0434 \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0436\u0443. \u0414\u0435\u043b\u0430\u0435\u0442 \u043e\u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435: \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435, \u0441 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e 1\/model-&gt;updateFactor, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 pix_data \u0432 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0441\u044d\u043c\u043f\u043b \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044f [x,y], \u0438 \u0442\u0430\u043a\u0436\u0435 \u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u044d\u043c\u043f\u043b\u043e\u0432 \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e\u0441\u044f \u0440\u044f\u0434\u043e\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u044f (\u0442\u043e\u0436\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e).<\/p>\n<p>  \u041d\u0443 \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f:<\/p>\n<pre><code class=\"cpp\">s32b libvibeModelUpdate_8u_C1R(vibeModel *model, const u8b *image_data, u8b *segmentation_map) {         s32b ad = model-&gt;stride - model-&gt;width;          if (!model || !image_data || !segmentation_map) return 1;         if (model-&gt;stride &lt; model-&gt;width) return 1;          u32b n=0;         for (u32b j=0; j &lt; model-&gt;height; j++)         {                 for (u32b i=0; i &lt; model-&gt;width; i++)                 { \t\t\t\/\/ \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e                         if (comparePixel(image_data[n], &(model-&gt;pixels[n]), model-&gt;matchingThreshold, model-&gt;matchingNumber))                         { \t\t\t\t\/\/ \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u0444\u043e\u043d\u043e\u043c - \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0435                                 segmentation_map[n] = 0;                                 updateModel(model, image_data[n], model-&gt;width, model-&gt;height, model-&gt;stride,i,j);                          }                         else                         { \t\t\t\t\/\/ \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0444\u043e\u043d\u0430                                 segmentation_map[n] = 0xFFU;                         }                         n++;                 }                 if (model-&gt;stride &gt; model-&gt;width)                         n+=ad;         }         return 0; } <\/code><\/pre>\n<p>  \u0414\u043b\u044f libvibeModelUpdate_8u_C3R \u0432\u0441\u0435 \u043e\u043f\u044f\u0442\u044c \u0436\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e.<\/p>\n<p>  \u041e\u0431\u0449\u0438\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u044f<br \/>  \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0441\u0440\u0435\u0434\u0438 \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c (\u0441\u0440\u0435\u0434\u0438 \u0438\u043c\u0435\u044e\u0449\u0438\u0445 \u0445\u043e\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043a \u0444\u043e\u043d\u0443 \u0438 \u0435\u0433\u043e \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u044b\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435). \u0417\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0432\u0448\u0438\u043c\u0441\u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e <a href=\"http:\/\/www2.ulg.ac.be\/telecom\/research\/vibe\/download.html\">\u0441\u043a\u0430\u0447\u0430\u0442\u044c<\/a> \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0438 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0435\u0433\u043e \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 avi&#8217;\u0448\u043a\u0435.    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/165677\/\"> http:\/\/habrahabr.ru\/post\/165677\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<h5>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/h5>\n<p>  \u041f\u0430\u0440\u0443 \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434, \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0438 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435\u043c \u0434\u0432\u0438\u0436\u0443\u0449\u0438\u0445\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u043d\u0435\u043c\u0430\u043b\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f \u0444\u043e\u043d\u0430, \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0442\u043e\u0442, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u043f\u043e\u0439\u0434\u0435\u0442 \u0440\u0435\u0447\u044c. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0435\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u2014 \u043a\u0443\u0447\u0430 \u043f\u0430\u0442\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u043d \u0437\u0430\u0449\u0438\u0449\u0435\u043d. \u041d\u043e \u043e\u0434\u043d\u043e \u0438\u0437 \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u044b\u0445 \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432 \u2014 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043f\u043e\u0434 Linux, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0435\u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445. \u041d\u0430 <a href=\"http:\/\/www2.ulg.ac.be\/telecom\/research\/vibe\/\">\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435<\/a> \u0441 \u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u044d\u0442\u0443 \u0441\u0430\u043c\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0430 \u0442\u0430\u043a\u0436\u0435 demo-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u043e\u0434 Windows \u0438 Android, \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043f\u0430\u0442\u0435\u043d\u0442\u044b (\u0433\u0434\u0435 \u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430) \u0438 \u043f\u0440\u043e\u0447\u0443\u044e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-165677","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/165677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=165677"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/165677\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=165677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=165677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=165677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}