// Do not call directly, even in child void VideoCallback(void *_rgb, uint32_t timestamp) { Mutex::ScopedLock lock(m_rgb_mutex); uint8_t* rgb = static_cast<uint8_t*>(_rgb); copy(rgb, rgb+getVideoBufferSize(), m_buffer_video.begin()); m_new_rgb_frame = true; }
/*! * \brief called if usb video event in Freenect::m_thread. * \param [out] _rgb poitns buffer where to save usb incoming video frame. * \param timestamp internal use to synchronize video & depth frames. * \see libfreenect.hpp Freenect::Freenect */ void Apikinect::VideoCallback(void *_rgb, uint32_t timestamp) { std::lock_guard<std::mutex> lock(m_rgb_mutex);//lock will be destroyed when exit VideoCallback uint8_t* rgb = static_cast<uint8_t*>(_rgb); copy(rgb, rgb+getVideoBufferSize(), m_buffer_video.begin()); m_new_rgb_frame = true; }
// Do not call directly even in child void VideoCallback(void* _rgb, uint32_t timestamp) { //std::cout << "RGB callback" << std::endl; m_rgb_mutex.lock(); uint8_t* rgb = static_cast<uint8_t*>(_rgb); std::copy(rgb, rgb+getVideoBufferSize(), m_buffer_video.begin()); m_new_rgb_frame = true; m_rgb_mutex.unlock(); };
void LGFreenectDevice::VideoCallback(void* _rgb, uint32_t timestamp) { static int frame = 0; frame++; //std::cout << "RGB callback (frame " << frame << ")" << std::endl; m_rgb_mutex.lock(); uint8_t* rgb = static_cast<uint8_t*>(_rgb); std::copy(rgb, rgb+getVideoBufferSize(), m_buffer_rgb.begin()); cv::Mat3b nMat(rgbMat); nMat.data = (uchar *) &m_buffer_rgb.front(); nMat.copyTo(rgbMat); m_new_rgb_frame = true; m_rgb_mutex.unlock(); //std::cout << "end callback" << std::endl; }
MyFreenectDevice(freenect_context *_ctx, int _index) : Freenect::FreenectDevice(_ctx, _index), m_buffer_depth(getDepthBufferSize()),m_buffer_video(getVideoBufferSize()), m_gamma(2048), m_new_rgb_frame(false), m_new_depth_frame(false) { for( unsigned int i = 0 ; i < 2048 ; i++) { float v = i/2048.0; v = std::pow(v, 3)* 6; m_gamma[i] = v*6*256; } }