Example #1
0
void consumer(void)
{
    int value;
    while (!done) {
        while (spsc_queue.pop(value))
            ++consumer_count;
    }

    while (spsc_queue.pop(value))
        ++consumer_count;
}
Example #2
0
/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  consumer
 *  Description:  处理图像线程,计算hog和显示
 * =====================================================================================
 */
void consumer(void)
{
	
	while (true){
		vector<Rect> found, found_filtered;
		spsc_queue.pop(showimg);
		hog.detectMultiScale(showimg, found, 0, Size(4,4), Size(0,0), 1.05, 2);
		for (i=0; i<found.size(); i++)
		{
			Rect r = found[i];
			for (j=0; j<found.size(); j++)
				if (j!=i && (r & found[j])==r)
					break;
			if (j==found.size())
				found_filtered.push_back(r);
		}
		for (i=0; i<found_filtered.size(); i++)
		{
			Rect r = found_filtered[i];
			r.x += cvRound(r.width*0.1);
			r.width = cvRound(r.width*0.8);
			r.y += cvRound(r.height*0.06);
			r.height = cvRound(r.height*0.9);
			rectangle(showimg, r.tl(), r.br(), cv::Scalar(0,255,0), 1);
		}
		imshow("1",showimg);
		waitKey(5);
	}

}
Example #3
0
void randn(float *array, int n)
{
    int consumed, consumer_count;
    consumer_count = 0;
    while (consumer_count < n)
        while ( consumed = spsc_queue.pop(&array[consumer_count], n-consumer_count) )
            consumer_count = consumer_count + consumed;
}