Beispiel #1
0
void Link::normalizeToDegree( const float& pos, const bool fw, const int id )
{
    if( id == linkId ) {
        linkRotate = pos;
        emit toProcess( linkRotate, id );
    }
    else {
        qDebug() << "Link::normalizeToDegree -> id != linkId\t";
    }
}
double full_minimization(vector<double>& coeffs)
{
  #pragma omp parallel for num_threads(NUM_PARALLEL)
	for (int i=0; i < all_threads.size(); i++)
	{
		vector<Vector3d> points;
		vector<double> twist_angles;
		Thread toProcess(all_threads[i]);	//must make a copy!
		toProcess.set_coeffs_normalized(coeffs[0], coeffs[1], coeffs[2]);

		toProcess.minimize_energy();
		toProcess.get_thread_data(points, twist_angles);


		scores_each_thread[i] = 0.0;
		for (int j=0; j < points.size(); j++)
		{
			scores_each_thread[i] += (points[j] - orig_points[i][j]).squaredNorm();
		}
		scores_each_thread[i] = sqrt(scores_each_thread[i]);
    angle_scores_each_thread[i] = abs(twist_angles[twist_angles.size()-2] - orig_twist_angles[i][twist_angles.size()-2]);
		//std::cout << "point score: " << scores_each_thread[i] << std::endl;
    //std::cout << "angle score: " << angle_scores_each_thread[i] << std::endl;
	}

	
	double fx = 0.0;

	for (int i=0; i < all_threads.size(); i++)
	{
		//fx += scores_each_thread[i];
    fx += angle_scores_each_thread[i];
	}

	fx /= (double)scores_each_thread.size();

	return fx;
}
Beispiel #3
0
/**
	Input: 1-Channel Grayscale Image
	Output: 1-Channel 8UC1 Inverted Binary Image
**/
cv::Mat Auvsi_Ocr::prepareTrainingImage(cv::Mat image, bool isShape, std::string imgPath)
{
	cv::Mat toProcess(image.size(),CV_8UC1);
	toProcess = image < 128;
	toProcess = Auvsi_Recognize::ProcessShape(toProcess);

	bool pathIsValid = imgPath.length() > 0;
	if (pathIsValid)
	{
		cv::Mat aClone = toProcess.clone();
		cv::circle(aClone, cv::Point(31,31), 32, cv::Scalar(128));
		IplImage imageIpl = aClone;
		
		cvSaveImage((imgPath + "_debug.jpg").c_str(), &imageIpl);
	}

	//cv::imshow("img",toProcess);
	//cv::waitKey(10);

	if (!Auvsi_Recognize::checkImage(toProcess))
		printf("WARNING: bad image in Auvsi_Ocr.cpp"); // this may not show up in Skynet

	return toProcess;
}
double oneStepDistance(vector<double>& coeffs)
{
  #pragma omp parallel for num_threads(NUM_PARALLEL)
	for (int i=0; i < all_threads.size(); i++)
	{
    double step_size = 0.01;
		vector<Vector3d> points;
		vector<double> twist_angles;
		Thread toProcess(all_threads[i]);	//must make a copy!
		toProcess.set_coeffs_normalized(coeffs[0], coeffs[1], coeffs[2]);

		toProcess.one_step_project(step_size);
		toProcess.get_thread_data(points, twist_angles);

		scores_each_thread[i] = 0.0;
		for (int j=0; j < points.size(); j++)
		{
			scores_each_thread[i] += (pow((points[j] - orig_points[i][j]).norm(),2));
		}
		scores_each_thread[i] = sqrt(scores_each_thread[i])/step_size;
	}

	
	double fx = 0.0;
	for (int i=0; i < all_threads.size(); i++)
	{
		fx += scores_each_thread[i];
	}

	fx /= (double)scores_each_thread.size();

	return fx;



}
Beispiel #5
0
void Link::setLinkRotate( float f_value )
{
    linkRotate = f_value;
    emit toProcess( linkRotate, linkId );
}