Created
September 1, 2011 22:42
-
-
Save ethanrublee/1187495 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef enum | |
{ | |
XN_IO_IMAGE_FORMAT_BAYER = 0, | |
XN_IO_IMAGE_FORMAT_YUV422 = 1, | |
XN_IO_IMAGE_FORMAT_JPEG = 2, | |
XN_IO_IMAGE_FORMAT_JPEG_420 = 3, | |
XN_IO_IMAGE_FORMAT_JPEG_MONO = 4, | |
XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422 = 5, | |
XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER = 6, | |
} XnIOImageFormats; | |
typedef enum XnProcessingType | |
{ | |
XN_PROCESSING_DONT_CARE = 0, XN_PROCESSING_HARDWARE = 1, XN_PROCESSING_SOFTWARE = 2, | |
} XnProcessingType; | |
void | |
set_sync_on() | |
{ | |
std::cout << " attempting to turn on sync..." << std::endl; | |
if (depthGenerator.IsCapabilitySupported(XN_CAPABILITY_FRAME_SYNC)) | |
{ | |
if (depthGenerator.GetFrameSyncCap().CanFrameSyncWith(imageGenerator) | |
&& !depthGenerator.GetFrameSyncCap().IsFrameSyncedWith(imageGenerator)) | |
{ | |
XnStatus status = depthGenerator.GetFrameSyncCap().FrameSyncWith(imageGenerator); | |
if (status != XN_STATUS_OK) | |
{ | |
NI_STATUS_ERROR("Failed to start frame sync"); | |
} | |
} | |
if (depthGenerator.GetFrameSyncCap().IsFrameSyncedWith(imageGenerator)) | |
{ | |
std::cout << "Successful sync between depth and image." << std::endl; | |
} | |
else | |
{ | |
std::cerr << "Depth/Image sync could not be enabled." << std::endl; | |
} | |
} | |
else | |
{ | |
std::cerr << "Depth/Image sync is not supported." << std::endl; | |
} | |
} | |
void | |
init_xtion_pro_live(bool registration, ResolutionMode m) | |
{ | |
XnUInt64 inputformat = XN_IO_IMAGE_FORMAT_YUV422; | |
if (m == SXGA_RES) | |
{ | |
inputformat = XN_IO_IMAGE_FORMAT_BAYER; | |
} | |
XnStatus status = imageGenerator.SetIntProperty("InputFormat", inputformat); | |
if (status != XN_STATUS_OK) | |
NI_STATUS_ERROR("Error setting the image input format. "); | |
status = imageGenerator.SetPixelFormat(XN_PIXEL_FORMAT_RGB24); | |
if (status != XN_STATUS_OK) | |
NI_STATUS_ERROR("Failed to SetPixelFormat: "); | |
if (registration) | |
{ | |
status = depthGenerator.SetIntProperty("RegistrationType", XN_PROCESSING_HARDWARE); | |
if (status != XN_STATUS_OK) | |
{ | |
NI_STATUS_ERROR("Error setting the registration type."); | |
} | |
} | |
set_sync_on(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment