00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00036 #include "Image.h"
00037
00038 #include "../core/Exception.h"
00039 #include "../DeviceManager.h"
00040
00041 namespace NIDevice
00042 {
00043 namespace Generator
00044 {
00045 Image::Image(NIDevice::Objects::KinectDevice* pDevice) : NIDevice::Core::GenericGenerator<xn::ImageGenerator, XN_NODE_TYPE_IMAGE>(pDevice)
00046 {
00047 SetOutputMode(XN_VGA_X_RES, XN_VGA_Y_RES, 30);
00048 }
00049
00050 Image::Image() : NIDevice::Core::GenericGenerator<xn::ImageGenerator, XN_NODE_TYPE_IMAGE>(0)
00051 {
00052
00053 }
00054
00055 Image::~Image()
00056 {
00057
00058 }
00059
00060 int Image::SetOutputMode(int xRes, int yRes, int nFps)
00061 {
00062 XnMapOutputMode map;
00063 map.nXRes = xRes;
00064 map.nYRes = yRes;
00065 map.nFPS = nFps;
00066
00067 nRetVal = GetGenerator().SetMapOutputMode(map);
00068 if (nRetVal != XN_STATUS_OK)
00069 {
00070
00071 KINECT_EXCEPT(NIDevice::Core::ExceptionKinect, GetNiDeviceMessage(), GetObjectTypeAsString());
00072 return nRetVal;
00073 }
00074
00075 return XN_STATUS_OK;
00076 }
00077
00078 const unsigned char* Image::GetImageBuffer()
00079 {
00080 boost::mutex::scoped_lock lock(GetParentDevice()->m_mutex);
00081 GetGenerator().GetMetaData(g_imageMD);
00082 return (const_cast<unsigned char*>(g_imageMD.Data()));
00083 }
00084
00085 void Image::GetImageSize(int &w, int &h)
00086 {
00087 width = g_imageMD.XRes();
00088 height = g_imageMD.YRes();
00089 w = width;
00090 h = height;
00091 }
00092 }
00093 }
00094