-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Orbbec: Support color channel for Stereo/Embedded S and supress warni…
…ngs we can not avoid.
- Loading branch information
Showing
9 changed files
with
1,551 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "AutoResetEvent.h" | ||
#include <mutex> | ||
#include <condition_variable> | ||
#include <thread> | ||
|
||
bool flag_ = false; | ||
std::mutex protect_; | ||
std::condition_variable signal_; | ||
|
||
void AutoResetEventSet() | ||
{ | ||
std::lock_guard<std::mutex> _(protect_); | ||
flag_ = true; | ||
signal_.notify_one(); | ||
} | ||
|
||
void AutoResetEventReset() | ||
{ | ||
std::lock_guard<std::mutex> _(protect_); | ||
flag_ = false; | ||
} | ||
|
||
bool AutoResetEventWaitOne() | ||
{ | ||
std::unique_lock<std::mutex> lk(protect_); | ||
while (!flag_) // prevent spurious wakeups from doing harm | ||
signal_.wait(lk); | ||
flag_ = false; // waiting resets the flag | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
#include <stdio.h> | ||
|
||
void AutoResetEventSet(); | ||
void AutoResetEventReset(); | ||
bool AutoResetEventWaitOne(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef __OB_COMMON_H__ | ||
#define __OB_COMMON_H__ | ||
|
||
|
||
//#include <XnStatus.h> | ||
#include <iostream> | ||
|
||
|
||
#define OB_LOG_INFO(args) printf("OB_INFO : ");printf(args) | ||
#define OB_LOG_ERROR(args) printf("OB_ERROR : ");printf(args) | ||
|
||
|
||
#endif // __OB_COMMON_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#ifndef __OB_UVCAPI_H__ | ||
#define __OB_UVCAPI_H__ | ||
|
||
|
||
#include <OniCTypes.h> | ||
#include <stdint.h> | ||
|
||
#include <vector> | ||
#include <map> | ||
#include <memory> | ||
#include <functional> | ||
#include <string> | ||
|
||
#include "AutoResetEvent.h" | ||
|
||
//To keep things simple, we should take the highest color resolution which matches the aspect ratio of the intrinsics and | ||
//has maximum FPS (in our case 30) | ||
|
||
//With this mode we can get up to 50fps, but depending on the illumination it can drop down to 15fps | ||
//#define UVC_COLOR_WIDTH 1280 | ||
//#define UVC_COLOR_HEIGHT 960 | ||
|
||
//With this mode we can get up to 26fps, but depending on the illumination it can drop down to 15fps | ||
//#define UVC_COLOR_WIDTH 2592 | ||
//#define UVC_COLOR_HEIGHT 1944 | ||
|
||
#define UVC_COLOR_MEDIASUBTYPE MEDIASUBTYPE_NV12 | ||
//#define UVC_COLOR_MEDIASUBTYPE MEDIASUBTYPE_MJPG //Also works, but needs more processing time | ||
//#define UVC_COLOR_MEDIASUBTYPE MEDIASUBTYPE_YUY2 //Delivers high framerates only for 640x480 or lower | ||
|
||
struct ObUVCDevice; | ||
|
||
void ProcessorCallback(const void *frame, int size, void *pstream); | ||
|
||
int ObUVCInit(int uvcColorWidth, int uvcColorHeight, bool uvcColorFlipImage); | ||
void ObUVCFillColorImage(unsigned char* colorData); | ||
void ObUVCShutdown(); | ||
void ObUVCWaitForNewColorImage(); | ||
void ConvertNV12ToRGBImage(unsigned char* nv12_image); | ||
void ConvertYUY2ToRGBImage(unsigned char* yuy2_image); | ||
void ConvertNV12ToRGBImageAndFlip(unsigned char* nv12_image); | ||
void ConvertYUY2ToRGBImageAndFlip(unsigned char* yuy2_image); | ||
|
||
int enumerate_all_devices(std::map<std::string, std::shared_ptr<ObUVCDevice>> &devices); | ||
int get_vendor_id(const ObUVCDevice & device); | ||
int get_product_id(const ObUVCDevice & device); | ||
|
||
void set_stream(ObUVCDevice & device, int subdevice_index, void * pstream); | ||
|
||
typedef std::function<void(const void * frame, int size, void *pstream)> video_channel_callback; | ||
void set_subdevice_mode(ObUVCDevice & device, int subdevice_index, video_channel_callback callback); | ||
|
||
void start_streaming(ObUVCDevice & device,int subdevice_index=0); | ||
void stop_streaming(ObUVCDevice & device, int subdevice_index=0); | ||
#endif |
Oops, something went wrong.