feat(uvc osx): yuyv format is right now

This commit is contained in:
Tiny 2018-12-21 14:17:08 +08:00
parent 2f5860bcb0
commit 263658834a
2 changed files with 10 additions and 66 deletions

View File

@ -35,7 +35,7 @@
if(bytes==3) color = true; if(bytes==3) color = true;
else color = false; else color = false;
buffer = new unsigned char[cam_width*cam_height*bytes]; buffer = new unsigned char[cam_width*cam_height*4];
return self; return self;
} }
@ -110,12 +110,14 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
} else { } else {
int size = cam_width*cam_height/2; int size = cam_width*cam_height;
for (int i=size;i>0;i--) { for (int i=size;i>0;i--) {
// yu
*dest++ = *src++; *dest++ = *src++;
src++; // src++;
// yv
*dest++ = *src++; *dest++ = *src++;
src++; // src++;
} }
} }
} }

View File

@ -122,59 +122,6 @@ void pv_sleep(int ms = 1) {
usleep(ms*1000); usleep(ms*1000);
} }
/*
struct CameraConfig {
char path[256];
int driver;
int device;
char name[256];
char src[256];
bool color;
bool frame;
int cam_format;
int src_format;
int buf_format;
int cam_width;
int cam_height;
float cam_fps;
int frame_width;
int frame_height;
int frame_xoff;
int frame_yoff;
int frame_mode;
int brightness;
int contrast;
int sharpness;
int gain;
int shutter;
int exposure;
int focus;
int gamma;
int white;
int powerline;
int backlight;
int saturation;
int hue;
int red;
int blue;
int green;
bool force;
bool operator < (const CameraConfig& c) const;
};
*/
struct device; struct device;
struct device : public AVfoundationCamera{ struct device : public AVfoundationCamera{
@ -267,17 +214,8 @@ struct device : public AVfoundationCamera{
void poll() { void poll() {
if (is_capturing) { if (is_capturing) {
// long start_time = VisionEngine::currentMicroSeconds();
cameraBuffer = getFrame(); cameraBuffer = getFrame();
if (cameraBuffer != NULL) { if (cameraBuffer != NULL) {
// cameraWriteBuffer = engine->ringBuffer->getNextBufferToWrite();
// if (cameraWriteBuffer!=NULL) {
// memcpy(cameraWriteBuffer,cameraBuffer,engine->ringBuffer->size());
// engine->framenumber_++;
// engine->ringBuffer->writeFinished();
// long driver_time = VisionEngine::currentMicroSeconds() - start_time;
// std::cout << "camera latency: " << driver_time/1000.0f << "ms" << std::endl;
// }
if (callback) { if (callback) {
callback(cameraBuffer, [this]() mutable { callback(cameraBuffer, [this]() mutable {
// todo // todo
@ -340,6 +278,10 @@ MYNTEYE_API std::vector<std::shared_ptr<device>> query_devices(
auto camerasConfig = findDevicesConfig(); auto camerasConfig = findDevicesConfig();
printConfig(camerasConfig); printConfig(camerasConfig);
for (unsigned int i = 0; i < camerasConfig.size(); i++) { for (unsigned int i = 0; i < camerasConfig.size(); i++) {
// if (strcmp(fstr[camerasConfig[i].cam_format], "yuyv") == 0) {
// printf("change fomat to buf_format 2\n");
// camerasConfig[i].buf_format = 2;
// }
auto dev = std::make_shared<device>(context, camerasConfig[i]); auto dev = std::make_shared<device>(context, camerasConfig[i]);
devices.push_back(dev); devices.push_back(dev);
} }