87 |
87 |
public:
|
88 |
88 |
static const int INVALID_PIXEL_VAL = 0;
|
89 |
89 |
|
90 |
|
CvCapture_OpenNI();
|
|
90 |
CvCapture_OpenNI( const char* filename = 0 );
|
91 |
91 |
virtual ~CvCapture_OpenNI();
|
92 |
92 |
|
93 |
93 |
virtual double getProperty(int propIdx);
|
... | ... | |
166 |
166 |
return m_isOpened;
|
167 |
167 |
}
|
168 |
168 |
|
169 |
|
CvCapture_OpenNI::CvCapture_OpenNI()
|
|
169 |
CvCapture_OpenNI::CvCapture_OpenNI( const char* filename )
|
170 |
170 |
{
|
171 |
171 |
XnStatus status = XN_STATUS_OK;
|
172 |
172 |
|
... | ... | |
180 |
180 |
// Initialize and configure the context.
|
181 |
181 |
if( context.Init() == XN_STATUS_OK )
|
182 |
182 |
{
|
|
183 |
if(filename == 0)
|
|
184 |
{
|
183 |
185 |
#ifdef HACK_WITH_XML
|
184 |
|
// Write configuration to the temporary file.
|
185 |
|
// This is a hack, because there is a bug in RunXmlScript().
|
186 |
|
// TODO: remove hack when bug in RunXmlScript() will be fixed.
|
187 |
|
std::string xmlFilename = cv::tempfile();
|
188 |
|
std::ofstream outfile( xmlFilename.c_str() );
|
189 |
|
outfile.write( XMLConfig.c_str(), XMLConfig.length() );
|
190 |
|
outfile.close();
|
|
186 |
// Write configuration to the temporary file.
|
|
187 |
// This is a hack, because there is a bug in RunXmlScript().
|
|
188 |
// TODO: remove hack when bug in RunXmlScript() will be fixed.
|
|
189 |
std::string xmlFilename = cv::tempfile();
|
|
190 |
std::ofstream outfile( xmlFilename.c_str() );
|
|
191 |
outfile.write( XMLConfig.c_str(), XMLConfig.length() );
|
|
192 |
outfile.close();
|
191 |
193 |
|
192 |
|
status = context.RunXmlScriptFromFile( xmlFilename.c_str() );
|
|
194 |
status = context.RunXmlScriptFromFile( xmlFilename.c_str() );
|
193 |
195 |
|
194 |
|
// Remove temporary configuration file.
|
195 |
|
remove( xmlFilename.c_str() );
|
|
196 |
// Remove temporary configuration file.
|
|
197 |
remove( xmlFilename.c_str() );
|
196 |
198 |
#else
|
197 |
|
status = context.RunXmlScript( XMLConfig.c_str() );
|
|
199 |
status = context.RunXmlScript( XMLConfig.c_str() );
|
198 |
200 |
#endif
|
|
201 |
}
|
|
202 |
else
|
|
203 |
{
|
|
204 |
status = context.OpenFileRecording(filename);
|
|
205 |
}
|
199 |
206 |
m_isOpened = ( status == XN_STATUS_OK );
|
200 |
207 |
}
|
201 |
208 |
|
... | ... | |
637 |
644 |
return 0;
|
638 |
645 |
}
|
639 |
646 |
|
|
647 |
CvCapture* cvCreateFileCapture_OpenNI( const char* filename )
|
|
648 |
{
|
|
649 |
// TODO devices enumeration (if several Kinects)
|
|
650 |
CvCapture_OpenNI* capture = new CvCapture_OpenNI(filename);
|
|
651 |
|
|
652 |
if( capture->isOpened() )
|
|
653 |
return capture;
|
|
654 |
|
|
655 |
delete capture;
|
|
656 |
return 0;
|
|
657 |
}
|
|
658 |
|
640 |
659 |
#endif
|