Пример #1
0
void FindOneWayDescriptorEx(int desc_count, const CvOneWayDescriptor* descriptors, IplImage* patch,
							float scale_min, float scale_max, float scale_step,
							int n, std::vector<int>& desc_idxs, std::vector<int>& pose_idxs,
							std::vector<float>& distances, std::vector<float>& scales,
							CvMat* avg, CvMat* eigenvectors)
{
	CvSize patch_size = descriptors[0].GetPatchSize();
	IplImage* input_patch;
	CvRect roi;

	input_patch= cvCreateImage(patch_size, IPL_DEPTH_8U, 1);
	roi = cvGetImageROI((IplImage*)patch);

	//  float min_distance = 1e10;
	std::vector<int> _desc_idxs;
	_desc_idxs.resize(n);
	std::vector<int> _pose_idxs;
	_pose_idxs.resize(n);
	std::vector<float> _distances;
	_distances.resize(n);


	for (int i=0;i<n;i++)
	{
		distances[i] = 1e10;
	}

	for(float cur_scale = scale_min; cur_scale < scale_max; cur_scale *= scale_step)
	{

		CvRect roi_scaled = resize_rect(roi, cur_scale);
		cvSetImageROI(patch, roi_scaled);
		cvResize(patch, input_patch);



		FindOneWayDescriptor(desc_count, descriptors, input_patch, n,_desc_idxs, _pose_idxs, _distances, avg, eigenvectors);
		for (int i=0;i<n;i++)
		{
			if(_distances[i] < distances[i])
			{
				distances[i] = _distances[i];
				desc_idxs[i] = _desc_idxs[i];
				pose_idxs[i] = _pose_idxs[i];
				scales[i] = cur_scale;
			}
		}
	}



	cvSetImageROI((IplImage*)patch, roi);
	cvReleaseImage(&input_patch);
}
Пример #2
0
void FindOneWayDescriptorEx(int desc_count, const CvOneWayDescriptor* descriptors, IplImage* patch,
							float scale_min, float scale_max, float scale_step,
							int& desc_idx, int& pose_idx, float& distance, float& scale,
							CvMat* avg, CvMat* eigenvectors)
{
	CvSize patch_size = descriptors[0].GetPatchSize();
	IplImage* input_patch;
	CvRect roi;

	input_patch= cvCreateImage(patch_size, IPL_DEPTH_8U, 1);
	roi = cvGetImageROI((IplImage*)patch);

	int _desc_idx, _pose_idx;
	float _distance;
	distance = 1e10;
	for(float cur_scale = scale_min; cur_scale < scale_max; cur_scale *= scale_step)
	{
		//        printf("Scale = %f\n", cur_scale);

		CvRect roi_scaled = resize_rect(roi, cur_scale);
		cvSetImageROI(patch, roi_scaled);
		cvResize(patch, input_patch);


#if 0
		if(roi.x > 244 && roi.y < 200)
		{
			cvNamedWindow("1", 1);
			cvShowImage("1", input_patch);
			cvWaitKey(0);
		}
#endif

		FindOneWayDescriptor(desc_count, descriptors, input_patch, _desc_idx, _pose_idx, _distance, avg, eigenvectors);
		if(_distance < distance)
		{
			distance = _distance;
			desc_idx = _desc_idx;
			pose_idx = _pose_idx;
			scale = cur_scale;
		}
	}


	cvSetImageROI((IplImage*)patch, roi);
	cvReleaseImage(&input_patch);

}
void CL_Window_Silver::on_resize(int old_width, int old_height)
{
	CL_Rect client_rect(3, 24, window->get_width() - 3, window->get_height() - 3);
	window->get_client_area()->set_position(client_rect);

	int xpos = window->get_width() - 20;

	if(button_close)
	{
		CL_Rect close_rect(xpos, 3, xpos + 17, 20);
		button_close->set_position(close_rect);
		xpos -= 18;
	}

	if(button_maximize)
	{
		CL_Rect close_rect(xpos, 3, xpos + 17, 20);
		button_maximize->set_position(close_rect);
		xpos -= 18;
	}

	if(button_minimize)
	{
		CL_Rect close_rect(xpos, 3, xpos + 17, 20);
		button_minimize->set_position(close_rect);
		xpos -= 18;
	}

	if(button_help)
	{
		CL_Rect close_rect(xpos, 3, xpos + 17, 20);
		button_help->set_position(close_rect);
	}

	CL_Rect move_rect(0, 0, window->get_width(), titlebar_height);
	move_handler->set_position(move_rect);
	
	CL_Rect resize_rect(window->get_width() - 3, window->get_height() - 3, window->get_width(), window->get_height());
	resize_handler->set_position(resize_rect);
}
Пример #4
0
void FindOneWayDescriptorEx(cv::flann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low,
                            int m_pose_count, IplImage* patch,
							float scale_min, float scale_max, float scale_step,
							int& desc_idx, int& pose_idx, float& distance, float& scale,
							CvMat* avg, CvMat* eigenvectors)
{
	IplImage* input_patch;
	CvRect roi;

	input_patch= cvCreateImage(patch_size, IPL_DEPTH_8U, 1);
	roi = cvGetImageROI((IplImage*)patch);

	int _desc_idx, _pose_idx;
	float _distance;
	distance = 1e10;
	for(float cur_scale = scale_min; cur_scale < scale_max; cur_scale *= scale_step)
	{
		//        printf("Scale = %f\n", cur_scale);

		CvRect roi_scaled = resize_rect(roi, cur_scale);
		cvSetImageROI(patch, roi_scaled);
		cvResize(patch, input_patch);

		FindOneWayDescriptor(m_pca_descriptors_tree, patch_size, m_pca_dim_low, m_pose_count, input_patch, _desc_idx, _pose_idx, _distance, avg, eigenvectors);
		if(_distance < distance)
		{
			distance = _distance;
			desc_idx = _desc_idx;
			pose_idx = _pose_idx;
			scale = cur_scale;
		}
	}


	cvSetImageROI((IplImage*)patch, roi);
	cvReleaseImage(&input_patch);

}