Results *FindHighestScoring_Threaded(Search *S, const int start, const int count, const int topk, unsigned char *bsig, unsigned char *bmask, int threadcount) { pthread_t searchthreads[threadcount]; struct searchthread_params params[threadcount]; for (int i = 0; i < threadcount; i++) { params[i].S = S; params[i].topk = topk; params[i].bsig = bsig; params[i].bmask = bmask; params[i].start = (count / threadcount * i) + start; params[i].count = count / threadcount; if (i == (threadcount - 1)) { // Add remaining to the last thread params[i].count += count - (count / threadcount * threadcount); } pthread_create(searchthreads+i, NULL, FindHighestScoring_work, params+i); } Results *R = NULL; Results *newR = NULL; for (int i = 0; i < threadcount; i++) { void *newR_void = newR; pthread_join(searchthreads[i], &newR_void); newR = newR_void; if (R) { MergeResults(R, newR); } else { R = newR; } } return R; }
Results *FindHighestScoring_Threaded_X(Search *S, const int start, const int count, const int topk, unsigned char *bsig, unsigned char *bmask, int threadcount) { pthread_t searchthreads[threadcount]; struct searchthread_params_x params[threadcount]; struct searchthread_params_x_shared *shared = malloc(sizeof(struct searchthread_params_x_shared)); shared->start = start; shared->count = count; shared->i = 0; shared->n = atoi(Config("SEARCH-JOBS")); for (int i = 0; i < threadcount; i++) { params[i].S = S; params[i].topk = topk; params[i].bsig = bsig; params[i].bmask = bmask; params[i].shared = shared; pthread_create(searchthreads+i, NULL, FindHighestScoring_work_x, params+i); } Results *R = NULL; Results *newR = NULL; for (int i = 0; i < threadcount; i++) { void *newR_void = newR; pthread_join(searchthreads[i], &newR_void); newR = newR_void; if (R) { MergeResults(R, newR); } else { R = newR; } } return R; }
CMat& CmCurveEx::CalSecDer_(CMat &img3f, int kSize) { Mat img1f[3], der1f[3], ornt1f[3]; split(img3f, img1f); for (int i = 0; i < 3; i++) { CalSecDer(img1f[i], kSize); _pDer1f.copyTo(der1f[i]); _pOrnt1f.copyTo(ornt1f[i]); } MergeResults(der1f, ornt1f, _pDer1f, _pOrnt1f); GaussianBlur(_pDer1f, _pDer1f, Size(3, 3), 0); return _pDer1f; }