Exemplo n.º 1
0
// blobtrack_sample.cpp
void FindObjectMain::process_blob()
{
	if(!blob_initialized)
	{
		blob_initialized = 1;
		
		blob_param.FGTrainFrames = 5;


/* Create FG Detection module: */
		blob_param.pFG = cvCreateFGDetectorBase(CV_BG_MODEL_FGD, NULL);
/* Create Blob Entrance Detection module: */
        blob_param.pBD = cvCreateBlobDetectorCC();
/* Create blob tracker module: */
        blob_param.pBT = cvCreateBlobTrackerCCMSPF();
/* Create whole pipline: */
        blob_pTracker = cvCreateBlobTrackerAuto1(&blob_param);
		
	}


/* Process: */
	IplImage*   pMask = NULL;

// Create aligned, RGB images
	if(!scene_image)
	{
		scene_image = cvCreateImage( 
			cvSize(scene_image_w, scene_image_h), 
			8, 
			3);
	}

// Temporary row pointers
	unsigned char **scene_rows = new unsigned char*[scene_image_h];
	for(int i = 0; i < scene_image_h; i++)
	{
		scene_rows[i] = (unsigned char*)(scene_image->imageData + i * scene_image_w * 3);
	}

	BC_CModels::transfer(scene_rows,
		get_input(scene_layer)->get_rows(),
		0,
		0,
		0,
		0,
		0,
		0,
		scene_x1,
		scene_y1,
		scene_w,
		scene_h,
		0,
		0,
		scene_w,
		scene_h,
		get_input(scene_layer)->get_color_model(),
		BC_RGB888,
		0,
		0,
		0);

	delete [] scene_rows;

    blob_pTracker->Process(scene_image, pMask);
printf("FindObjectMain::process_blob %d %ld %d\n", __LINE__, get_source_position(), blob_pTracker->GetBlobNum());


#if 0
	if(blob_pTracker->GetFGMask())
	{
		IplImage* pFG = blob_pTracker->GetFGMask();
printf("FindObjectMain::process_blob %d %ld\n", __LINE__, get_source_position());
		
// Temporary row pointers
		unsigned char **mask_rows = new unsigned char*[scene_image_h];
		for(int i = 0; i < scene_image_h; i++)
		{
			mask_rows[i] = (unsigned char*)(pFG->imageData + i * scene_image_w);
		}

		for(int i = 0; i < scene_image_h; i++)
		{
			switch(get_input(scene_layer)->get_color_model())
			{
				case BC_RGB888:
					APPLY_MASK(unsigned char, 0xff, 3, 0)
					break;
				case BC_RGB_FLOAT:
					APPLY_MASK(float, 1.0, 3, 0)
					break;
				case BC_YUV888:
					APPLY_MASK(unsigned char, 0xff, 3, 1)
					break;
				case BC_RGBA8888:
					APPLY_MASK(unsigned char, 0xff, 4, 0)
					break;
				case BC_RGBA_FLOAT:
					APPLY_MASK(float, 1.0, 4, 0)
					break;
				case BC_YUVA8888:
					APPLY_MASK(unsigned char, 0xff, 4, 1)
					break;
			}
		}

		delete [] mask_rows;

		
	}
Exemplo n.º 2
0
CvBlobDetector* CvCreateBlobDetectorCC() { return cvCreateBlobDetectorCC(); }