11#pragma once
22
3- #include < iostream>
43#include " libfreenect.hpp"
5- #include " Driver/OniDriverAPI.h"
64#include " PS1080.h"
5+ #include " Utility.hpp"
76
87
9- struct RetrieveKey
10- {
11- template <typename T> typename T::first_type
12- operator ()(T pair) const {
13- return pair.first ;
14- }
15- };
16-
17- // "extension constructor" for OniVideoMode struct
18- static OniVideoMode makeOniVideoMode (OniPixelFormat pixel_format, int resolution_x, int resolution_y, int frames_per_second)
19- {
20- OniVideoMode mode;
21- mode.pixelFormat = pixel_format;
22- mode.resolutionX = resolution_x;
23- mode.resolutionY = resolution_y;
24- mode.fps = frames_per_second;
25- return mode;
26- }
27-
28- static bool operator ==(const OniVideoMode& left, const OniVideoMode& right)
29- {
30- return (left.pixelFormat == right.pixelFormat && left.resolutionX == right.resolutionX
31- && left.resolutionY == right.resolutionY && left.fps == right.fps );
32- }
33- static bool operator <(const OniVideoMode& left, const OniVideoMode& right) { return (left.resolutionX *left.resolutionY < right.resolutionX *right.resolutionY ); }
34-
358namespace FreenectDriver
369{
37- template < typename T > std::string to_string (const T& n)
38- {
39- std::ostringstream oss;
40- oss << n;
41- return oss.str ();
42- }
43-
44- static void WriteMessage (std::string info)
45- {
46- std::cout << " OpenNI2-FreenectDriver: " << info << std::endl;
47- }
48-
49- // DriverServices is set in DeviceDriver.cpp so all files can call errorLoggerAppend()
50- static oni::driver::DriverServices* DriverServices;
51- static void LogError (std::string error)
52- {
53- // errorLoggerAppend() doesn't seem to go anywhere, so call WriteMessage also
54- WriteMessage (" (ERROR) " + error);
55-
56- if (DriverServices != NULL )
57- DriverServices->errorLoggerAppend (std::string (" OpenNI2-FreenectDriver: " + error).c_str ());
58- }
59-
6010 class VideoStream : public oni ::driver::StreamBase
6111 {
6212 private:
@@ -77,7 +27,12 @@ namespace FreenectDriver
7727 VideoStream (Freenect::FreenectDevice* device) :
7828 frame_id (1 ),
7929 device (device),
80- mirroring (false ) { }
30+ mirroring (false )
31+ {
32+ // joy of structs
33+ memset (&cropping, 0 , sizeof (cropping));
34+ memset (&video_mode, 0 , sizeof (video_mode));
35+ }
8136 // ~VideoStream() { stop(); }
8237
8338 void buildFrame (void * data, uint32_t timestamp)
0 commit comments