Skip to content

Commit b7af622

Browse files
committed
Removes Opencv for good
1 parent 547c590 commit b7af622

File tree

7 files changed

+18
-72
lines changed

7 files changed

+18
-72
lines changed

examples/protonect/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,13 @@ SET(LIBRARY_OUTPUT_PATH ${MY_DIR}/lib)
3939

4040
# dependencies
4141
FIND_PACKAGE(PkgConfig) # try find PKGConfig as it will be used if found
42-
FIND_PACKAGE(OpenCV)
4342
FIND_PACKAGE(LibUSB REQUIRED)
4443
FIND_PACKAGE(TurboJPEG REQUIRED) #does not provide a package-config file
45-
IF(OpenCV_FOUND)
46-
SET(LIBFREENECT2_OPENCV_FOUND 1)
47-
ENDIF()
4844

4945
# Add includes
5046
INCLUDE_DIRECTORIES(
5147
"${MY_DIR}/include"
5248
${LIBFREENECT2_THREADING_INCLUDE_DIR}
53-
${OpenCV_INCLUDE_DIRS}
5449
${LibUSB_INCLUDE_DIRS}
5550
${TurboJPEG_INCLUDE_DIRS}
5651
)
@@ -106,7 +101,6 @@ SET(SOURCES
106101
)
107102

108103
SET(LIBRARIES
109-
${OpenCV_LIBRARIES}
110104
${LibUSB_LIBRARIES}
111105
${TurboJPEG_LIBRARIES}
112106
${LIBFREENECT2_THREADING_LIBRARIES}

examples/protonect/Protonect.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@
3636
#ifdef LIBFREENECT2_WITH_OPENGL_SUPPORT
3737
#include "viewer.h"
3838
#endif
39-
#ifdef LIBFREENECT2_OPENCV_FOUND
40-
#include <opencv2/opencv.hpp>
41-
#endif
4239

4340

4441
bool protonect_shutdown = false;
@@ -140,10 +137,8 @@ int main(int argc, char *argv[])
140137

141138
libfreenect2::Registration* registration = new libfreenect2::Registration(dev->getIrCameraParams(), dev->getColorCameraParams());
142139

143-
#if defined(LIBFREENECT2_WITH_OPENGL_SUPPORT) && !defined(LIBFREENECT2_OPENCV_FOUND)
144140
Viewer viewer;
145141
viewer.initialize();
146-
#endif
147142

148143
while(!protonect_shutdown)
149144
{
@@ -154,22 +149,12 @@ int main(int argc, char *argv[])
154149

155150
registration->apply(rgb, depth, &undistorted, &registered);
156151

157-
#if defined(LIBFREENECT2_WITH_OPENGL_SUPPORT) && !defined(LIBFREENECT2_OPENCV_FOUND)
158152
viewer.addFrame("RGB", rgb);
159153
viewer.addFrame("ir", ir);
160154
viewer.addFrame("depth", depth);
161155
viewer.addFrame("registered", &registered);
162156

163157
protonect_shutdown = viewer.render();
164-
#else
165-
cv::imshow("rgb", cv::Mat(rgb->height, rgb->width, CV_8UC4, rgb->data));
166-
cv::imshow("ir", cv::Mat(ir->height, ir->width, CV_32FC1, ir->data) / 20000.0f);
167-
cv::imshow("depth", cv::Mat(depth->height, depth->width, CV_32FC1, depth->data) / 4500.0f);
168-
cv::imshow("undistorted", cv::Mat(undistorted.height, undistorted.width, CV_32FC1, undistorted.data) / 4500.0f);
169-
cv::imshow("registered", cv::Mat(registered.height, registered.width, CV_8UC4, registered.data));
170-
int key = cv::waitKey(1);
171-
protonect_shutdown = protonect_shutdown || (key > 0 && ((key & 0xFF) == 27)); // shutdown on escape
172-
#endif
173158

174159
listener.release(frames);
175160
//libfreenect2::this_thread::sleep_for(libfreenect2::chrono::milliseconds(100));

examples/protonect/include/libfreenect2/config.h.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,4 @@
4747

4848
#cmakedefine LIBFREENECT2_THREADING_TINYTHREAD
4949

50-
#cmakedefine LIBFREENECT2_OPENCV_FOUND
51-
5250
#endif // LIBFREENECT2_CONFIG_H

examples/protonect/include/libfreenect2/depth_packet_processor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ class LIBFREENECT2_API OpenGLDepthPacketProcessor : public DepthPacketProcessor
140140
#endif // LIBFREENECT2_WITH_OPENGL_SUPPORT
141141

142142
// TODO: push this to some internal namespace
143-
// use pimpl to hide opencv dependency
144143
class CpuDepthPacketProcessorImpl;
145144

146145
class LIBFREENECT2_API CpuDepthPacketProcessor : public DepthPacketProcessor

examples/protonect/src/cpu_depth_packet_processor.cpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
#include <libfreenect2/resource.h>
2929
#include <libfreenect2/protocol/response.h>
3030

31-
#ifdef LIBFREENECT2_OPENCV_FOUND
32-
#include <opencv2/opencv.hpp>
33-
#endif
3431
#include <iostream>
3532
#include <fstream>
3633

@@ -219,7 +216,7 @@ class CpuDepthPacketProcessorImpl
219216
double timing_acc;
220217
double timing_acc_n;
221218

222-
double timing_current_start;
219+
std::chrono::time_point<std::chrono::high_resolution_clock> timing_current_start;
223220

224221
bool enable_bilateral_filter, enable_edge_filter;
225222
DepthPacketProcessor::Parameters params;
@@ -235,35 +232,28 @@ class CpuDepthPacketProcessorImpl
235232

236233
timing_acc = 0.0;
237234
timing_acc_n = 0.0;
238-
timing_current_start = 0.0;
239235

240236
enable_bilateral_filter = true;
241237
enable_edge_filter = true;
242238

243239
flip_ptables = true;
244240
}
245241

246-
void startTiming()
247-
{
248-
#ifdef LIBFREENECT2_OPENCV_FOUND
249-
timing_current_start = cv::getTickCount();
250-
#endif
242+
void startTiming() {
243+
timing_current_start = std::chrono::high_resolution_clock::now();
251244
}
252245

253-
void stopTiming()
254-
{
255-
#ifdef LIBFREENECT2_OPENCV_FOUND
256-
timing_acc += (cv::getTickCount() - timing_current_start) / cv::getTickFrequency();
246+
void stopTiming() {
247+
timing_acc += std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - timing_current_start).count();
257248
timing_acc_n += 1.0;
258249

259250
if(timing_acc_n >= 100.0)
260251
{
261252
double avg = (timing_acc / timing_acc_n);
262-
std::cout << "[CpuDepthPacketProcessor] avg. time: " << (avg * 1000) << "ms -> ~" << (1.0/avg) << "Hz" << std::endl;
253+
std::cout << "[CpuDepthPacketProcessor] avg. time: " << avg << "ms -> ~" << (1000.0/avg) << "Hz" << std::endl;
263254
timing_acc = 0.0;
264255
timing_acc_n = 0.0;
265256
}
266-
#endif
267257
}
268258

269259
void newIrFrame()

examples/protonect/src/opencl_depth_packet_processor.cpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
#include <libfreenect2/resource.h>
2929
#include <libfreenect2/protocol/response.h>
3030

31-
#ifdef LIBFREENECT2_OPENCV_FOUND
32-
#include <opencv2/opencv.hpp>
33-
#endif
3431
#include <iostream>
3532
#include <fstream>
3633
#include <sstream>
@@ -83,7 +80,7 @@ class OpenCLDepthPacketProcessorImpl
8380
double timing_acc;
8481
double timing_acc_n;
8582

86-
double timing_current_start;
83+
std::chrono::time_point<std::chrono::high_resolution_clock> timing_current_start;
8784

8885
Frame *ir_frame, *depth_frame;
8986

@@ -151,7 +148,6 @@ class OpenCLDepthPacketProcessorImpl
151148

152149
timing_acc = 0.0;
153150
timing_acc_n = 0.0;
154-
timing_current_start = 0.0;
155151
image_size = 512 * 424;
156152

157153
deviceInitialized = initDevice(deviceId);
@@ -542,27 +538,21 @@ class OpenCLDepthPacketProcessorImpl
542538
return true;
543539
}
544540

545-
void startTiming()
546-
{
547-
#ifdef LIBFREENECT2_OPENCV_FOUND
548-
timing_current_start = cv::getTickCount();
549-
#endif
541+
void startTiming() {
542+
timing_current_start = std::chrono::high_resolution_clock::now();
550543
}
551544

552-
void stopTiming()
553-
{
554-
#ifdef LIBFREENECT2_OPENCV_FOUND
555-
timing_acc += (cv::getTickCount() - timing_current_start) / cv::getTickFrequency();
545+
void stopTiming() {
546+
timing_acc += std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - timing_current_start).count();
556547
timing_acc_n += 1.0;
557548

558549
if(timing_acc_n >= 100.0)
559550
{
560551
double avg = (timing_acc / timing_acc_n);
561-
std::cout << "[OpenCLDepthPacketProcessor] avg. time: " << (avg * 1000) << "ms -> ~" << (1.0 / avg) << "Hz" << std::endl;
552+
std::cout << "[OpenCLDepthPacketProcessor] avg. time: " << avg << "ms -> ~" << (1000.0/avg) << "Hz" << std::endl;
562553
timing_acc = 0.0;
563554
timing_acc_n = 0.0;
564555
}
565-
#endif
566556
}
567557

568558
void newIrFrame()

examples/protonect/src/turbo_jpeg_rgb_packet_processor.cpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
*/
2626

2727
#include <libfreenect2/rgb_packet_processor.h>
28-
#ifdef LIBFREENECT2_OPENCV_FOUND
29-
#include <opencv2/opencv.hpp>
30-
#endif
3128
#include <turbojpeg.h>
3229
#include <iostream>
3330

@@ -45,7 +42,7 @@ class TurboJpegRgbPacketProcessorImpl
4542
double timing_acc;
4643
double timing_acc_n;
4744

48-
double timing_current_start;
45+
std::chrono::time_point<std::chrono::high_resolution_clock> timing_current_start;
4946

5047
TurboJpegRgbPacketProcessorImpl()
5148
{
@@ -59,7 +56,6 @@ class TurboJpegRgbPacketProcessorImpl
5956

6057
timing_acc = 0.0;
6158
timing_acc_n = 0.0;
62-
timing_current_start = 0.0;
6359
}
6460

6561
~TurboJpegRgbPacketProcessorImpl()
@@ -78,27 +74,21 @@ class TurboJpegRgbPacketProcessorImpl
7874
frame = new Frame(1920, 1080, tjPixelSize[TJPF_BGRX]);
7975
}
8076

81-
void startTiming()
82-
{
83-
#ifdef LIBFREENECT2_OPENCV_FOUND
84-
timing_current_start = cv::getTickCount();
85-
#endif
77+
void startTiming() {
78+
timing_current_start = std::chrono::high_resolution_clock::now();
8679
}
8780

88-
void stopTiming()
89-
{
90-
#ifdef LIBFREENECT2_OPENCV_FOUND
91-
timing_acc += (cv::getTickCount() - timing_current_start) / cv::getTickFrequency();
81+
void stopTiming() {
82+
timing_acc += std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - timing_current_start).count();
9283
timing_acc_n += 1.0;
9384

9485
if(timing_acc_n >= 100.0)
9586
{
9687
double avg = (timing_acc / timing_acc_n);
97-
std::cout << "[TurboJpegRgbPacketProcessor] avg. time: " << (avg * 1000) << "ms -> ~" << (1.0/avg) << "Hz" << std::endl;
88+
std::cout << "[TurboJpegRgbPacketProcessor] avg. time: " << avg << "ms -> ~" << (1000.0/avg) << "Hz" << std::endl;
9889
timing_acc = 0.0;
9990
timing_acc_n = 0.0;
10091
}
101-
#endif
10292
}
10393
};
10494

0 commit comments

Comments
 (0)