Skip to content

Commit

Permalink
Add Freenect2Replay API and depth implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
smokhov authored and xlz committed Dec 6, 2017
1 parent 0856a20 commit 03e5b6f
Show file tree
Hide file tree
Showing 2 changed files with 577 additions and 0 deletions.
63 changes: 63 additions & 0 deletions include/libfreenect2/libfreenect2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <libfreenect2/frame_listener.hpp>
#include <libfreenect2/packet_pipeline.h>
#include <string>
#include <vector>

namespace libfreenect2
{
Expand Down Expand Up @@ -274,6 +275,68 @@ class LIBFREENECT2_API Freenect2
Freenect2& operator=(const Freenect2&);
};

class Freenect2ReplayDevice;

/**
* Library context to create and open replay devices.
*
* You openDevice() and control the device with returned Freenect2ReplayDevice object.
*
* You may open devices with custom PacketPipeline.
* After passing a PacketPipeline object to libfreenect2 do not use or free the object,
* libfreenect2 will take care. If openDevice() fails the PacketPipeline object will get
* deleted. A new PacketPipeline object has to be created each time a device is opened.
*/
class LIBFREENECT2_API Freenect2Replay
{
public:
/**
* Creates the context.
*/
Freenect2Replay();
virtual ~Freenect2Replay();

/**
* @return Replay device serial number.
*/
std::string getDefaultDeviceSerialNumber();

/** Open device by a collection of stored frame filenames with default pipeline.
* See filename format below.
* @param frame_filenames A list of filenames for stored frames.
* @return New device object, or NULL on failure
*/
Freenect2Device *openDevice(const std::vector<std::string>& frame_filenames);

/** Open device by a collection of stored frame filenames with the specified pipeline.
* File names non-compliant with the filename format will be skipped.
* Filename format: <prefix>_<timestamp>_<sequence>.<suffix>
* <prefix> - a string of the filename, anything
* <timestamp> -- packet timestamp as in pipeline packets
* <sequence> -- frame sequence number in the packet
* <suffix> -- .depth, .jpg, or .jpeg (case insensitive)
* @param frame_filenames A list of filenames for stored frames.
* @param factory New PacketPipeline instance. This is always automatically freed.
* @return New device object, or NULL on failure
*/
Freenect2Device *openDevice(const std::vector<std::string>& frame_filenames, const PacketPipeline *factory);

private:
typedef std::vector<Freenect2ReplayDevice*> DeviceVector;
DeviceVector devices_;

bool initialized;

void addDevice(Freenect2ReplayDevice *device);
void removeDevice(Freenect2ReplayDevice *device);
void clearDevices();
int getNumDevices();

/* Disable copy and assignment constructors */
Freenect2Replay(const Freenect2Replay&);
Freenect2Replay& operator=(const Freenect2Replay&);
};

///@}
} /* namespace libfreenect2 */
#endif /* LIBFREENECT2_HPP_ */
Loading

0 comments on commit 03e5b6f

Please sign in to comment.