我想从这个静态变量中得到一个常量变量。
#define video_mode_count 12
static freenect_frame_mode supported_video_modes[video_mode_count] = {
// reserved, resolution, format, bytes, width, height, data_bits_per_pixel, padding_bits_per_pixel, framerate, is_valid
{MAKE_RESERVED(FREENECT_RESOLUTION_HIGH, FREENECT_VIDEO_RGB), FREENECT_RESOLUTION_HIGH, {FREENECT_VIDEO_RGB}, 1280*1024*3, 1280, 1024, 24, 0, 10, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB), FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_RGB}, 640*480*3, 640, 480, 24, 0, 30, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_HIGH, FREENECT_VIDEO_BAYER), FREENECT_RESOLUTION_HIGH, {FREENECT_VIDEO_BAYER}, 1280*1024, 1280, 1024, 8, 0, 10, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_BAYER), FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_BAYER}, 640*480, 640, 480, 8, 0, 30, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_HIGH, FREENECT_VIDEO_IR_8BIT), FREENECT_RESOLUTION_HIGH, {FREENECT_VIDEO_IR_8BIT}, 1280*1024, 1280, 1024, 8, 0, 10, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_IR_8BIT), FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_IR_8BIT}, 640*488, 640, 488, 8, 0, 30, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_HIGH, FREENECT_VIDEO_IR_10BIT), FREENECT_RESOLUTION_HIGH, {FREENECT_VIDEO_IR_10BIT}, 1280*1024*2, 1280, 1024, 10, 6, 10, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_IR_10BIT), FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_IR_10BIT}, 640*488*2, 640, 488, 10, 6, 30, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_HIGH, FREENECT_VIDEO_IR_10BIT_PACKED), FREENECT_RESOLUTION_HIGH, {FREENECT_VIDEO_IR_10BIT_PACKED}, 1280*1024*10/8, 1280, 1024, 10, 0, 10, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_IR_10BIT_PACKED), FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_IR_10BIT_PACKED}, 640*488*10/8, 640, 488, 10, 0, 30, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_YUV_RGB), FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_YUV_RGB}, 640*480*3, 640, 480, 24, 0, 15, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_YUV_RAW), FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_YUV_RAW}, 640*480*2, 640, 480, 16, 0, 15, 1 },};
现在我需要写一些东西
const FREENECT_VIDEO_RGB = [ An instance in the type of freenect_frame_mode ]
如何以该格式声明const var?
原始代码来自:
https://github.com/OpenKinect/libfreenect/blob/master/src/cameras.c#L42
我需要将const var freenect_frame_mode传递给它,看看它是否返回-1:
https://github.com/OpenKinect/libfreenect/blob/master/src/cameras.c#L1152
int freenect_set_video_mode(freenect_device* dev, const freenect_frame_mode mode)
{
freenect_context *ctx = dev->parent;
if (dev->video.running) {
FN_ERROR("Tried to set video mode while stream is active\n");
return -1;
}
// Verify that the mode passed in is actually in the supported mode list
int found = 0;
int i;
for(i = 0 ; i < video_mode_count; i++) {
if (supported_video_modes[i].reserved == mode.reserved) {
found = 1;
break;
}
}
if (!found) {
FN_ERROR("freenect_set_video_mode: freenect_frame_mode provided is invalid\n");
return -1;
}
freenect_resolution res = RESERVED_TO_RESOLUTION(mode.reserved);
freenect_video_format fmt = (freenect_video_format)RESERVED_TO_FORMAT(mode.reserved);
dev->video_format = fmt;
dev->video_resolution = res;
// Now that we've changed video format and resolution, we need to update
// registration tables.
freenect_fetch_reg_info(dev);
return 0;
}
我现在只是停止使用该功能。
谢谢!
答案 0 :(得分:3)
好吧,如果你想获得一个数组的元素,你可以使用标准语法array[index]
。
const freenect_frame_mode FREENECT_VIDEO_RGB = supported_video_modes[5];
例如。
如果您想了解更多信息,则需要显示更多代码,即这些符号的定义。