Skip to content

Commit 03e5b6f

Browse files
smokhovxlz
authored andcommitted
Add Freenect2Replay API and depth implementation
1 parent 0856a20 commit 03e5b6f

File tree

2 files changed

+577
-0
lines changed

2 files changed

+577
-0
lines changed

include/libfreenect2/libfreenect2.hpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <libfreenect2/frame_listener.hpp>
3434
#include <libfreenect2/packet_pipeline.h>
3535
#include <string>
36+
#include <vector>
3637

3738
namespace libfreenect2
3839
{
@@ -274,6 +275,68 @@ class LIBFREENECT2_API Freenect2
274275
Freenect2& operator=(const Freenect2&);
275276
};
276277

278+
class Freenect2ReplayDevice;
279+
280+
/**
281+
* Library context to create and open replay devices.
282+
*
283+
* You openDevice() and control the device with returned Freenect2ReplayDevice object.
284+
*
285+
* You may open devices with custom PacketPipeline.
286+
* After passing a PacketPipeline object to libfreenect2 do not use or free the object,
287+
* libfreenect2 will take care. If openDevice() fails the PacketPipeline object will get
288+
* deleted. A new PacketPipeline object has to be created each time a device is opened.
289+
*/
290+
class LIBFREENECT2_API Freenect2Replay
291+
{
292+
public:
293+
/**
294+
* Creates the context.
295+
*/
296+
Freenect2Replay();
297+
virtual ~Freenect2Replay();
298+
299+
/**
300+
* @return Replay device serial number.
301+
*/
302+
std::string getDefaultDeviceSerialNumber();
303+
304+
/** Open device by a collection of stored frame filenames with default pipeline.
305+
* See filename format below.
306+
* @param frame_filenames A list of filenames for stored frames.
307+
* @return New device object, or NULL on failure
308+
*/
309+
Freenect2Device *openDevice(const std::vector<std::string>& frame_filenames);
310+
311+
/** Open device by a collection of stored frame filenames with the specified pipeline.
312+
* File names non-compliant with the filename format will be skipped.
313+
* Filename format: <prefix>_<timestamp>_<sequence>.<suffix>
314+
* <prefix> - a string of the filename, anything
315+
* <timestamp> -- packet timestamp as in pipeline packets
316+
* <sequence> -- frame sequence number in the packet
317+
* <suffix> -- .depth, .jpg, or .jpeg (case insensitive)
318+
* @param frame_filenames A list of filenames for stored frames.
319+
* @param factory New PacketPipeline instance. This is always automatically freed.
320+
* @return New device object, or NULL on failure
321+
*/
322+
Freenect2Device *openDevice(const std::vector<std::string>& frame_filenames, const PacketPipeline *factory);
323+
324+
private:
325+
typedef std::vector<Freenect2ReplayDevice*> DeviceVector;
326+
DeviceVector devices_;
327+
328+
bool initialized;
329+
330+
void addDevice(Freenect2ReplayDevice *device);
331+
void removeDevice(Freenect2ReplayDevice *device);
332+
void clearDevices();
333+
int getNumDevices();
334+
335+
/* Disable copy and assignment constructors */
336+
Freenect2Replay(const Freenect2Replay&);
337+
Freenect2Replay& operator=(const Freenect2Replay&);
338+
};
339+
277340
///@}
278341
} /* namespace libfreenect2 */
279342
#endif /* LIBFREENECT2_HPP_ */

0 commit comments

Comments
 (0)