invisible
changeset 1:fdbd55eaa14e
add frame class, mutices
author | Eleni Maria Stea <eleni@mutantstargoat.com> |
---|---|
date | Sat, 05 Oct 2013 19:02:40 +0300 |
parents | 80df8030105b |
children | b0b90ef993a0 |
files | .hgignore src/frame.cc src/frame.h src/kinect.cc |
diffstat | 4 files changed, 51 insertions(+), 22 deletions(-) [+] |
line diff
1.1 --- a/.hgignore Sat Oct 05 16:03:08 2013 +0300 1.2 +++ b/.hgignore Sat Oct 05 19:02:40 2013 +0300 1.3 @@ -1,4 +1,5 @@ 1.4 syntax: glob 1.5 +*.orig 1.6 *.o 1.7 *.settings 1.8 *.cproject
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/src/frame.cc Sat Oct 05 19:02:40 2013 +0300 2.3 @@ -0,0 +1,27 @@ 2.4 +#include <stdio.h> 2.5 +#include <pthread.h> 2.6 + 2.7 +#include "frame.h" 2.8 + 2.9 +static pthread_mutex_t video_mutex = PTHREAD_MUTEX_INITIALIZER; 2.10 +static pthread_mutex_t depth_mutex = PTHREAD_MUTEX_INITIALIZER; 2.11 + 2.12 +void init_frame_mx() 2.13 +{ 2.14 + pthread_mutex_init(&video_mutex, NULL); 2.15 + pthread_mutex_init(&depth_mutex, NULL); 2.16 +} 2.17 + 2.18 +void video_cb(freenect_device *kin_dev, void *rgb, uint32_t time) 2.19 +{ 2.20 + pthread_mutex_lock(&video_mutex); 2.21 + printf("Started video.\n"); 2.22 + pthread_mutex_unlock(&video_mutex); 2.23 +} 2.24 + 2.25 +void depth_cb(freenect_device *kin_dev, void *depth, uint32_t time) 2.26 +{ 2.27 + pthread_mutex_lock(&depth_mutex); 2.28 + printf("Started depth.\n"); 2.29 + pthread_mutex_unlock(&depth_mutex); 2.30 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/src/frame.h Sat Oct 05 19:02:40 2013 +0300 3.3 @@ -0,0 +1,20 @@ 3.4 +#ifndef FRAME_H_ 3.5 +#define FRAME_H_ 3.6 + 3.7 +#include <libfreenect.h> 3.8 + 3.9 +class Frame { 3.10 +private: 3.11 + int width; 3.12 + int height; 3.13 + 3.14 +public: 3.15 + Frame(); 3.16 + 3.17 +}; 3.18 + 3.19 +void init_frame_mx(); 3.20 +void video_cb(freenect_device *kin_dev, void *rgb, uint32_t time); 3.21 +void depth_cb(freenect_device *kin_dev, void *depth, uint32_t time); 3.22 + 3.23 +#endif // FRAME_H_
4.1 --- a/src/kinect.cc Sat Oct 05 16:03:08 2013 +0300 4.2 +++ b/src/kinect.cc Sat Oct 05 19:02:40 2013 +0300 4.3 @@ -1,13 +1,9 @@ 4.4 #include <stdio.h> 4.5 #include <pthread.h> 4.6 #include <libfreenect.h> 4.7 + 4.8 #include "kinect.h" 4.9 - 4.10 -static void video_cb(freenect_device *kin_dev, void *rgb, uint32_t time); 4.11 -static void depth_cb(freenect_device *kin_dev, void *depth, uint32_t time); 4.12 - 4.13 -static pthread_mutex_t video_mutex = PTHREAD_MUTEX_INITIALIZER; 4.14 -static pthread_mutex_t depth_mutex = PTHREAD_MUTEX_INITIALIZER; 4.15 +#include "frame.h" 4.16 4.17 bool init_kinect(freenect_context **kin_ctx, freenect_device **kin_dev, KinectParams *kin_params) 4.18 { 4.19 @@ -42,8 +38,7 @@ 4.20 return false; 4.21 } 4.22 4.23 - pthread_mutex_init(&video_mutex, NULL); 4.24 - pthread_mutex_init(&depth_mutex, NULL); 4.25 + init_frame_mx(); 4.26 4.27 freenect_set_video_callback(*kin_dev, video_cb); 4.28 freenect_set_depth_callback(*kin_dev, depth_cb); 4.29 @@ -86,17 +81,3 @@ 4.30 freenect_close_device(kin_dev); 4.31 freenect_shutdown(kin_ctx); 4.32 } 4.33 - 4.34 -void video_cb(freenect_device *kin_dev, void *rgb, uint32_t time) 4.35 -{ 4.36 - pthread_mutex_lock(&video_mutex); 4.37 - printf("Started video.\n"); 4.38 - pthread_mutex_unlock(&video_mutex); 4.39 -} 4.40 - 4.41 -void depth_cb(freenect_device *kin_dev, void *depth, uint32_t time) 4.42 -{ 4.43 - pthread_mutex_lock(&depth_mutex); 4.44 - printf("Started depth.\n"); 4.45 - pthread_mutex_unlock(&depth_mutex); 4.46 -}