Exemplo n.º 1
0
// Set up Tango Configuration handle, and connecting all callbacks.
bool TangoData::SetConfig() {
  // Get the default TangoConfig.
  config_ = TangoService_getConfig(TANGO_CONFIG_DEFAULT);
  if (config_ == NULL) {
    LOGE("TangoService_getConfig(): Failed");
    return false;
  }

  // Enable depth.
  if (TangoConfig_setBool(config_, "config_enable_depth", true) !=
      TANGO_SUCCESS) {
    LOGE("config_enable_depth Failed");
    return false;
  }

  // Enable color.
  if (TangoConfig_setBool(config_, "config_enable_color_camera", true) !=
      TANGO_SUCCESS) {
    LOGE("config_enable_color_camera Failed");
    return false;
  }

  // Get library version string from service.
  if (TangoConfig_getString(
          config_, "tango_service_library_version",
          const_cast<char*>(
              TangoData::GetInstance().lib_version_string.c_str()),
          kVersionStringLength) != TANGO_SUCCESS) {
    LOGE("Get tango_service_library_version Failed");
    return false;
  }

  // Get max point cloud elements. The value is used for allocating
  // the depth buffer.
  int temp = 0;
  if (TangoConfig_getInt32(config_, "max_point_cloud_elements", &temp) !=
      TANGO_SUCCESS) {
    LOGE("Get max_point_cloud_elements Failed");
    return false;
  }
  max_vertex_count = static_cast<uint32_t>(temp);

  // Forward allocate the maximum size of depth buffer.
  // max_vertex_count is the vertices count, max_vertex_count*3 is
  // the actual float buffer size.
  depth_buffer = new float[3 * max_vertex_count];

  return true;
}
TangoDevicePointCloud::TangoDevicePointCloud(
#if PLATFORM_ANDROID
	TangoConfig config_
#endif
	)
{
	UE_LOG(ProjectTangoPlugin, Log, TEXT("TangoDevicePointCloud::TangoDevicePointCloud: Creating TangoDevicePointCloud!"));
	//Setting up Point Cloud Buffers

#if PLATFORM_ANDROID

	pthread_mutex_init(&xyzij_mutex,NULL);

	int max_point_cloud_elements = 0;
	bool success = TangoConfig_getInt32(config_, "max_point_cloud_elements", &max_point_cloud_elements) == TANGO_SUCCESS;
	uint32_t MaxPointCloudVertexCount = static_cast<uint32_t>(max_point_cloud_elements);

	if (success)
	{
		UE_LOG(ProjectTangoPlugin, Log, TEXT("TangoDevicePointCloud::TangoDevicePointCloud: allocations"));
		pthread_mutex_lock(&xyzij_mutex); 
		VertCount = 0;
		VertCapacity = MaxPointCloudVertexCount;
		PointCloudValues.Reserve(static_cast<int32_t>(max_point_cloud_elements));

		RawData = new float[MaxPointCloudVertexCount][3];
		RawDataB = new float[MaxPointCloudVertexCount][3];
		pthread_mutex_unlock(&xyzij_mutex);

	}
	else
	{
		UE_LOG(ProjectTangoPlugin, Warning, TEXT("TangoDevicePointCloud::TangoDevicePointCloud: construction failed because read of max_point_cloud_elements was not successful."));
	}

#endif
	UE_LOG(ProjectTangoPlugin, Log, TEXT("TangoDevicePointCloud::TangoDevicePointCloud: Creating TangoDevicePointCloud FINISHED"));
}