示例#1
0
void pose_estimator_thread_function()
{
    while (true)
    {
        if (initialized)
            pose_estimator.compute(*point_vec_ptr);

        Sleep(100);
    }
}
示例#2
0
void setup_on_first_frame()
{
    console_log("on first frame");

    ipc->send_message("menu_plus", "set status", "verifying serial number");
    serial_number = camera->getSerialNumber();

    if (serial_number.size() == 10)
    {
        string char_string = "";
        int char_count = 0;
        for (char& c : serial_number)
        {
            char_string += c;

            ++char_count;
            if (char_count == 4)
                break;
        }

        if (char_string == "0101")
            serial_verified = true;
    }

    if (!serial_verified)
        wait_for_device();

    ipc->send_message("menu_plus", "set loading progress", "10");
    console_log("serial number: " + serial_number);

    data_path_current_module = data_path + slash + serial_number;

    int x_accel;
    int y_accel;
    int z_accel;
    camera->getAccelerometerValues(&x_accel, &y_accel, &z_accel);    
    
    Point3f heading = imu.compute_azimuth(x_accel, y_accel, z_accel);

    ipc->send_message("menu_plus", "set status", "loading calibration data");
    reprojector.load(*ipc, true);
    ipc->send_message("menu_plus", "set loading progress", "40");

    ipc->send_message("menu_plus", "set status", "initializing camera");
    CameraInitializerNew::init(camera);

    ipc->send_message("menu_plus", "set status", "loading pose data");
    pose_estimator.init();
    ipc->send_message("menu_plus", "set loading progress", "70");

    ipc->send_message("menu_plus", "set status", "starting cursor subprocess");

#ifdef _WIN32
    child_module_name = "win_cursor_plus";
    
    if (IsWindows8OrGreater())
        child_module_path = executable_path + slash + "win_cursor_plus" + slash + "win_cursor_plus" + extension0;
    else
        child_module_path = executable_path + slash + "win_cursor_plus_fallback" + slash + "win_cursor_plus" + extension0;

#elif __APPLE__
    //todo: port to OSX
#endif

    ipc->map_function("toggle imshow", [](const string message_body)
    {
        if (enable_imshow)
            enable_imshow = false;
        else
            enable_imshow = true;
    });

    ipc->map_function("load settings", [](const string message_body)
    {
        load_settings();
    });

    ipc->send_message("menu_plus", "set loading progress", "100");
}
void on_first_frame()
{
	bool serial_verfied = false;
	serial_number = camera->getSerialNumber();

	if (serial_number.size() == 10)
	{
		string char_string = "";
		int char_count = 0;
		for (char& c : serial_number)
		{
			char_string += c;

			++char_count;
			if (char_count == 4)
				break;
		}

		if (char_string == "0101")
			serial_verfied = true;
	}

	if (!serial_verfied)
	{
		hide_cursors();

		COUT << "please reconnect your Touch+ sensor" << endl;
		COUT << "restarting" << endl;

		wait_for_device();
	}

	data_path_current_module = data_path + "\\" + serial_number;

	int x_accel;
	int y_accel;
	int z_accel;
	camera->getAccelerometerValues(&x_accel, &y_accel, &z_accel);
	
	Point3d heading = imu.compute_azimuth(x_accel, y_accel, z_accel);

	// if (heading.y > 60)
		// mode = "tool";
	// else
		mode = "surface";

	ipc->send_message("menu_plus", "show notification", "Please wait:Initializing Touch+ Software");

	reprojector.load(*ipc);
	CameraInitializerNew::init(camera);
	pose_estimator.init();

	if (mode == "surface")
	{
		child_module_name = "win_cursor_plus";

		if (IsWindows8OrGreater())
			child_module_path = executable_path + "\\win_cursor_plus\\win_cursor_plus.exe";
		else
			child_module_path = executable_path + "\\win_cursor_plus_fallback\\win_cursor_plus.exe";

		ipc->open_udp_channel("win_cursor_plus");
		ipc->send_message("menu_plus", "show window", "");	
		ipc->send_message("menu_plus", "show wiggle", "");
	}
	else
	{
		ipc->open_udp_channel("unity_demo", 3333);
		ipc->send_message("menu_plus", "hide window", "");
	}

	ipc->map_function("toggle imshow", [](const string message_body)
	{
		if (enable_imshow)
		{
			enable_imshow = false;
			destroyAllWindows();
		}
		else
			enable_imshow = true;
	});

	ipc->map_function("load settings", [](const string message_body)
	{
		load_settings();
	});

	increment_wait_count = true;
}
/* Estimate the pose given a file.*/
candidates_t *estimate(void *estimator, char filename[]) {
  PoseEstimator *e = static_cast<PoseEstimator*>(estimator);
  vector<Candidate> candidates = e->estimate(string(filename));
	Candidate::sort(candidates);
  return candidates_to_candidates_t(candidates);
}