-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logger.h
73 lines (56 loc) · 1.84 KB
/
Logger.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Logger.h
*
* Created on: 15 Jun 2012
* Author: thomas
*/
#ifndef LOGGER_H_
#define LOGGER_H_
#include <zlib.h>
#include <limits>
#include <cassert>
#include <iostream>
#include <opencv2/opencv.hpp>
#include <boost/format.hpp>
#include <boost/thread.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/thread/condition_variable.hpp>
#include "OpenNI/openni_device.h"
#include "OpenNI/openni_driver.h"
#include "OpenNI/openni_exception.h"
#include "OpenNI/openni_depth_image.h"
#include "OpenNI/openni_image.h"
#include "ThreadMutexObject.h"
class Logger
{
public:
Logger();
virtual ~Logger();
void startWriting(std::string filename);
void stopWriting();
std::pair<std::pair<uint8_t *, uint8_t *>, int64_t> frameBuffers[10];
ThreadMutexObject<int> latestDepthIndex;
private:
std::pair<uint8_t *, int64_t> imageBuffers[10];
ThreadMutexObject<int> latestImageIndex;
boost::shared_ptr<openni_wrapper::OpenNIDevice> m_device;
int64_t m_lastImageTime;
int64_t m_lastDepthTime;
int depth_compress_buf_size;
uint8_t * depth_compress_buf;
CvMat * encodedImage;
int lastWritten;
boost::thread * writeThread;
ThreadMutexObject<bool> writing;
std::string filename;
void setupDevice(const std::string & deviceId);
void startSynchronization();
void stopSynchronization();
void encodeJpeg(cv::Vec<unsigned char, 3> * rgb_data);
void imageCallback(boost::shared_ptr<openni_wrapper::Image> image, void * cookie);
void depthCallback(boost::shared_ptr<openni_wrapper::DepthImage> depth_image, void * cookie);
void writeData();
};
#endif /* LOGGER_H_ */