C++ (Qt)for(int y = 0; y < sh; ++y) { for(int x = 0; x < sw; ++x) { int scale_y = 16 * y; int m_scale_y = scale_y + 16; int scale_x = 16 * x; int m_scale_x = scale_x + 16; for(int sy = scale_y; sy < m_scale_y; ++sy) { for(int sx = scale_x; sx < m_scale_x; ++sx) { int i = sy * width + sx; int koef = i + width; curbuf[i] = abs(curbuf[i] - curbuf[koef+1]) + abs(curbuf[koef] - curbuf[i+1]); if(abs(prevbuf[i] - curbuf[i]) > _sensitive) p.append(i); } } if(p.size() > _treshold) {mutex.lock(); points.append(p); mutex.unlock(); is_detect = true;} p.clear(); }}
C++ (Qt)int A,B,C,D;int i, x, y, sx, sy;uchar *buf;uchar *rbuf;for(y = 0; y < sh; ++y) { for(x = 0; x < sw; ++x) { i = (y*width + x)*16; for(sy = 16; sy > 0; --sy, i+=width-16) { for(sx = 16; sx > 0; --sx, ++i) { buf = curbuf+i; rbuf = buf; A = *rbuf; D = *(++rbuf); C = *(rbuf+=width); B = *(++rbuf); A = ((A>B)?A-B:B-A) + (C>D)?C-D:D-C; *buf = A; B = prevbuf[i]; if(((A>B)?A-B:B-A) > _sensitive) p.append(i); } } if(p.size() > _treshold) {mutex.lock(); points.append(p); mutex.unlock(); is_detect = true;} p.clear(); }}
QList<int> p;...if(abs(prevbuf[i] - curbuf[i]) > _sensitive) p.append(i);...if(p.size() > _treshold) {mutex.lock(); points.append(p); mutex.unlock(); is_detect = true;}p.clear();...... QList<int> points = _motion->getPoints(); for(int i = 0; i < points.size(); ++i) {vdata[points.at(i)] = 255;}
int sens[16*16];int sens_count;for(y = 0; y < sh; ++y) { for(x = 0; x < sw; ++x) { sens_count = 0;......... if(((A>B)?A-B:B-A) > _sensitive) {sens[sens_count]=i, sens_count++;} } } if(sens_count > _treshold) { mutex.lock(); for(int i=0; i<sens_count; ++i) {points.append(sens[i]);} mutex.unlock(); is_detect = true; } }}
C++ (Qt)int sens[16*16];int sens_count; int sw = (width / 16);int sh = (height / 16); bool is_detect = false;int A,B,C,D;int i, x, y, sx, sy;uchar *buf;uchar *rbuf;for(y = 0; y < sh; ++y) { for(x = 0; x < sw; ++x) { i = (y*width + x)*16; sens_count = 0; for(sy = 16; sy != 0; --sy, i+=width-16) { for(sx = 16; sx != 0; --sx, ++i) { buf = curbuf+i; rbuf = buf; A = *rbuf; D = *(++rbuf); C = *(rbuf+=width-1); B = *(++rbuf); A = ((A>B)?A-B:B-A) + (C>D)?C-D:D-C; *buf = A; B = prevbuf[i]; if(((A>B)?A-B:B-A) > _sensitive) {sens[sens_count]=i, sens_count++;}/* curbuf[i] = abs(curbuf[i] - curbuf[i+width+1]) + abs(curbuf[i+width] - curbuf[i+1]); if(abs(prevbuf[i] - curbuf[i]) > _sensitive) {sens[sens_count]=i, sens_count++;}*/ } } if(sens_count > _treshold) { mutex.lock(); for(int i=0; i<sens_count; ++i) {points.append(sens[i]);} mutex.unlock(); is_detect = true; } }}
buf = curbuf+i;rbuf = buf;A = *rbuf;C = *(++rbuf);B = *(rbuf+=(width-1));D = *(++rbuf);A = ((A>D)?A-D:D-A) + ((B>C)?B-C:C-B);*buf = A;B = prevbuf[i];if(((B>A)?B-A:A-B) > _sensitive) p.append(i);