void followPlanet(jrPlanet *pPlanet) {
	camSet(pPlanet->afPosition[0], pPlanet->afPosition[1], pPlanet->afPosition[2] + 6000.0f, g_Camera);
}
Ejemplo n.º 2
0
void test_camRecursiveKeypoints()
{
	CamImage image, dest;
	CamKeypoints points;
	int i;
	const int x = 8;
	int angle;
	double costheta;
	double sintheta;

	const int xp[4] = {-1, 1, 1, -1};
	const int yp[4] = {-1, -1, 1, 1};
	CamWarpingParams params;

	printf("Recursive keypoints detection :\n");
	camAllocateImage(&image, 256, 256, CAM_DEPTH_8U);
	camAllocateKeypoints(&points, 100);

	camSet(&image, 0);
	//     camDrawRectangle(&image, 102, 120, 156, 152, 128);
	//     camFillColor(&image, 103, 121, 128, -1);
	camDrawRectangle(&image, 120, 50, 150, 70, 28);
	camDrawRectangle(&image, 100, 35, 180, 90, 180);
	//     camFillColor(&image, 123, 36, 128, -1);
	//
	//     camDrawCircle(&image, 50, 50, 10, 128);
	//     camFillColor(&image, 50, 50, 128, -1);
	//     camDrawCircle(&image, 80, 50, 5, 128);
	//     camFillColor(&image, 80, 50, 128, -1);
	//     camDrawCircle(&image, 100, 50, 3, 128);
	//     camFillColor(&image, 100, 50, 128, -1);
	#if 1
	angle = 20;
	costheta = cos(angle * 2 * M_PI / 360);
	sintheta = sin(angle * 2 * M_PI / 360);
	for (i = 0; i < 4; i++) {
		params.p[i].x = (int)floor((costheta * xp[i] - sintheta * yp[i]) * 15 + 0.5);
		params.p[i].y = (int)floor((sintheta * xp[i] + costheta * yp[i]) * 15 + 0.5);
		params.p[i].x += 192;
		params.p[i].y += 192;
	}
	for (i = 0; i < 4; i++) {
		camDrawLine(&image, params.p[i].x, params.p[i].y, params.p[(i+1)%4].x, params.p[(i+1)%4].y, 128);
	}
	camFillColor(&image, 192, 192, 128, -1);

	angle = 30;
	costheta = cos(angle * 2 * M_PI / 360);
	sintheta = sin(angle * 2 * M_PI / 360);
	for (i = 0; i < 4; i++) {
		params.p[i].x = (int)floor((costheta * xp[i] - sintheta * yp[i]) * 10 + 0.5);
		params.p[i].y = (int)floor((sintheta * xp[i] + costheta * yp[i]) * 10 + 0.5);
		params.p[i].x += 50;
		params.p[i].y += 192;
	}

	for (i = 0; i < 4; i++) {
		camDrawLine(&image, params.p[i].x, params.p[i].y, params.p[(i+1)%4].x, params.p[(i+1)%4].y, 128);
	}
	camFillColor(&image, 50, 192, 128, -1);

	#endif
	dest.imageData = NULL;

	camKeypointsRecursiveDetector(&image, NULL, &points, 20, 0);
	for (i = 0; i < points.nbPoints; i++) {
		printf("x=%d y=%d value=%d scale=%d size=%d angle=%d\n", points.keypoint[i]->x, points.keypoint[i]->y, points.keypoint[i]->value, points.keypoint[i]->scale, points.keypoint[i]->size, points.keypoint[i]->angle);
	}
	camDrawKeypoints(&points, &image, 192);
	camSavePGM(&image, "output/keypoints_recursive.pgm");

	camDeallocateImage(&image);
	camDeallocateImage(&dest);
	camFreeKeypoints(&points);
}