style(uvc osx): CameraEngine code style fix.
This commit is contained in:
parent
55cd7cddd0
commit
cf79c71c1d
|
@ -12,27 +12,40 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include "CameraEngine.h"
|
#include "CameraEngine.h"
|
||||||
|
|
||||||
const char* dstr[] = { "default","dc1394","ps3eye","raspi","uvccam","","","","","","file","folder"};
|
const char* dstr[] = {"default", "dc1394", "ps3eye", "raspi",
|
||||||
|
"uvccam", "", "", "", "", "", "file", "folder"};
|
||||||
const char* fstr[] = { "unknown", "mono8", "mono16", "rgb8", "rgb16", "mono16s", "rgb16s", "raw8", "raw16", "rgba", "yuyv", "uyvy", "yuv411", "yuv444", "yuv420p", "yuv410p", "yvyu", "yuv211", "", "", "jpeg", "mjpeg", "mpeg", "mpeg2", "mpeg4", "h263", "h264", "", "", "", "dvpal", "dvntsc" };
|
|
||||||
|
|
||||||
|
const char* fstr[] = { "unknown", "mono8", "mono16", "rgb8",
|
||||||
|
"rgb16", "mono16s", "rgb16s", "raw8", "raw16", "rgba",
|
||||||
|
"yuyv", "uyvy", "yuv411", "yuv444", "yuv420p", "yuv410p",
|
||||||
|
"yvyu", "yuv211", "", "", "jpeg", "mjpeg", "mpeg", "mpeg2",
|
||||||
|
"mpeg4", "h263", "h264", "", "", "", "dvpal", "dvntsc" };
|
||||||
|
|
||||||
void CameraEngine::printInfo() {
|
void CameraEngine::printInfo() {
|
||||||
printf("camera: %s\n", cfg->name);
|
printf("camera: %s\n", cfg->name);
|
||||||
printf("driver: %s\n", dstr[cfg->driver]);
|
printf("driver: %s\n", dstr[cfg->driver]);
|
||||||
printf("codec: %s\n", fstr[cfg->cam_format]);
|
printf("codec: %s\n", fstr[cfg->cam_format]);
|
||||||
if (cfg->frame_mode < 0) {
|
if (cfg->frame_mode < 0) {
|
||||||
if (cfg->cam_fps==(int)cfg->cam_fps) printf("format: %dx%d, %dfps\n",cfg->frame_width,cfg->frame_height,(int)cfg->cam_fps);
|
if (cfg->cam_fps == static_cast<int>(cfg->cam_fps)) {
|
||||||
else printf("format: %dx%d, %.1ffps\n",cfg->frame_width,cfg->frame_height,cfg->cam_fps);
|
printf("format: %dx%d, %dfps\n", cfg->frame_width,
|
||||||
|
cfg->frame_height, static_cast<int>(cfg->cam_fps));
|
||||||
|
} else {
|
||||||
|
printf("format: %dx%d, %.1ffps\n", cfg->frame_width,
|
||||||
|
cfg->frame_height, cfg->cam_fps);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf("format7_%d: %dx%d\n", cfg->frame_mode,
|
||||||
|
cfg->frame_width, cfg->frame_height);
|
||||||
}
|
}
|
||||||
else printf("format7_%d: %dx%d\n",cfg->frame_mode,cfg->frame_width,cfg->frame_height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::setMinMaxConfig(CameraConfig *cam_cfg, std::vector<CameraConfig> cfg_list) {
|
void CameraEngine::setMinMaxConfig(CameraConfig *cam_cfg,
|
||||||
if ((cam_cfg->cam_width>0) && (cam_cfg->cam_height>0) && (cam_cfg->cam_fps>0)) return;
|
std::vector<CameraConfig> cfg_list) {
|
||||||
|
if ((cam_cfg->cam_width > 0) &&
|
||||||
|
(cam_cfg->cam_height > 0) &&
|
||||||
|
(cam_cfg->cam_fps > 0)) return;
|
||||||
|
|
||||||
int max_width = 0;
|
int max_width = 0;
|
||||||
int max_height = 0;
|
int max_height = 0;
|
||||||
|
@ -42,34 +55,57 @@ void CameraEngine::setMinMaxConfig(CameraConfig *cam_cfg, std::vector<CameraConf
|
||||||
float min_fps = INT_MAX;
|
float min_fps = INT_MAX;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < cfg_list.size(); i++) {
|
for (unsigned int i = 0; i < cfg_list.size(); i++) {
|
||||||
if (cfg_list[i].cam_format!=cam_cfg->cam_format) continue; // wrong format
|
if (cfg_list[i].cam_format != cam_cfg->cam_format)
|
||||||
if (cfg_list[i].frame_mode!=cam_cfg->frame_mode) continue; // wrong format7
|
continue; // wrong format
|
||||||
|
if (cfg_list[i].frame_mode != cam_cfg->frame_mode)
|
||||||
|
continue; // wrong format7
|
||||||
|
|
||||||
if (cfg_list[i].cam_width>max_width) max_width = cfg_list[i].cam_width;
|
if (cfg_list[i].cam_width > max_width)
|
||||||
if (cfg_list[i].cam_width<min_width) min_width = cfg_list[i].cam_width;
|
max_width = cfg_list[i].cam_width;
|
||||||
|
if (cfg_list[i].cam_width < min_width)
|
||||||
|
min_width = cfg_list[i].cam_width;
|
||||||
|
|
||||||
if (cfg_list[i].cam_height>max_height) max_height = cfg_list[i].cam_height;
|
if (cfg_list[i].cam_height > max_height)
|
||||||
if (cfg_list[i].cam_width<min_height) min_height = cfg_list[i].cam_height;
|
max_height = cfg_list[i].cam_height;
|
||||||
|
if (cfg_list[i].cam_width < min_height)
|
||||||
|
min_height = cfg_list[i].cam_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((cam_cfg->cam_width==SETTING_MAX) || (cam_cfg->cam_width>max_width)) cam_cfg->cam_width = max_width;
|
if ((cam_cfg->cam_width == SETTING_MAX) ||
|
||||||
else if ((cam_cfg->cam_width==SETTING_MIN) || (cam_cfg->cam_width<min_width)) cam_cfg->cam_width = min_width;
|
(cam_cfg->cam_width > max_width)) {
|
||||||
if ((cam_cfg->cam_height==SETTING_MAX) || (cam_cfg->cam_height>max_height)) cam_cfg->cam_height = max_height;
|
cam_cfg->cam_width = max_width;
|
||||||
else if ((cam_cfg->cam_height==SETTING_MIN) || (cam_cfg->cam_height<min_height)) cam_cfg->cam_height = min_height;
|
} else if ((cam_cfg->cam_width == SETTING_MIN) ||
|
||||||
|
(cam_cfg->cam_width < min_width)) {
|
||||||
|
cam_cfg->cam_width = min_width;
|
||||||
|
}
|
||||||
|
if ((cam_cfg->cam_height == SETTING_MAX) ||
|
||||||
|
(cam_cfg->cam_height > max_height)) {
|
||||||
|
cam_cfg->cam_height = max_height;
|
||||||
|
} else if ((cam_cfg->cam_height == SETTING_MIN) ||
|
||||||
|
(cam_cfg->cam_height < min_height)) {
|
||||||
|
cam_cfg->cam_height = min_height;
|
||||||
|
}
|
||||||
if (cam_cfg->cam_fps > 0) return;
|
if (cam_cfg->cam_fps > 0) return;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < cfg_list.size(); i++) {
|
for (unsigned int i = 0; i < cfg_list.size(); i++) {
|
||||||
if (cfg_list[i].cam_format!=cam_cfg->cam_format) continue; // wrong format
|
if (cfg_list[i].cam_format != cam_cfg->cam_format)
|
||||||
if (cfg_list[i].frame_mode!=cam_cfg->frame_mode) continue; // wrong format7
|
continue; // wrong format
|
||||||
if ((cfg_list[i].cam_width!=cam_cfg->cam_width) || (cfg_list[i].cam_height!=cam_cfg->cam_height)) continue; // wrong size
|
if (cfg_list[i].frame_mode != cam_cfg->frame_mode)
|
||||||
|
continue; // wrong format7
|
||||||
|
if ((cfg_list[i].cam_width != cam_cfg->cam_width) ||
|
||||||
|
(cfg_list[i].cam_height!= cam_cfg->cam_height))
|
||||||
|
continue; // wrong size
|
||||||
|
|
||||||
if (cfg_list[i].cam_fps > max_fps) max_fps = cfg_list[i].cam_fps;
|
if (cfg_list[i].cam_fps > max_fps) max_fps = cfg_list[i].cam_fps;
|
||||||
if (cfg_list[i].cam_fps < min_fps) min_fps = cfg_list[i].cam_fps;
|
if (cfg_list[i].cam_fps < min_fps) min_fps = cfg_list[i].cam_fps;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((cam_cfg->cam_fps==SETTING_MAX) || (cam_cfg->cam_fps>max_fps)) cam_cfg->cam_fps = max_fps;
|
if ((cam_cfg->cam_fps == SETTING_MAX) ||
|
||||||
if ((cam_cfg->cam_fps==SETTING_MIN) || (cam_cfg->cam_fps<min_fps)) cam_cfg->cam_fps = min_fps;
|
(cam_cfg->cam_fps > max_fps))
|
||||||
|
cam_cfg->cam_fps = max_fps;
|
||||||
|
if ((cam_cfg->cam_fps == SETTING_MIN) ||
|
||||||
|
(cam_cfg->cam_fps < min_fps))
|
||||||
|
cam_cfg->cam_fps = min_fps;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CameraEngine::showSettingsDialog(bool lock) {
|
bool CameraEngine::showSettingsDialog(bool lock) {
|
||||||
|
@ -83,7 +119,7 @@ void CameraEngine::control(unsigned char key) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case VALUE_DECREASE:
|
case VALUE_DECREASE:
|
||||||
step = getCameraSettingStep(currentCameraSetting);
|
step = getCameraSettingStep(currentCameraSetting);
|
||||||
if (step==1) step = (int)((float)ctrl_max/256.0f);
|
if (step == 1) step = ctrl_max * 1.0f / 256.0f;
|
||||||
if (step < 1) step = 1;
|
if (step < 1) step = 1;
|
||||||
ctrl_val -= step;
|
ctrl_val -= step;
|
||||||
if (ctrl_val <ctrl_min) ctrl_val = ctrl_min;
|
if (ctrl_val <ctrl_min) ctrl_val = ctrl_min;
|
||||||
|
@ -91,7 +127,7 @@ void CameraEngine::control(unsigned char key) {
|
||||||
break;
|
break;
|
||||||
case VALUE_INCREASE:
|
case VALUE_INCREASE:
|
||||||
step = getCameraSettingStep(currentCameraSetting);
|
step = getCameraSettingStep(currentCameraSetting);
|
||||||
if (step==1) step = (int)((float)ctrl_max/256.0f);
|
if (step == 1) step = ctrl_max * 1.0f / 256.0f;
|
||||||
if (step < 1) step = 1;
|
if (step < 1) step = 1;
|
||||||
ctrl_val += step;
|
ctrl_val += step;
|
||||||
if (ctrl_val > ctrl_max) ctrl_val = ctrl_max;
|
if (ctrl_val > ctrl_max) ctrl_val = ctrl_max;
|
||||||
|
@ -100,23 +136,29 @@ void CameraEngine::control(unsigned char key) {
|
||||||
case SETTING_PREVIOUS:
|
case SETTING_PREVIOUS:
|
||||||
currentCameraSetting--;
|
currentCameraSetting--;
|
||||||
if (currentCameraSetting < 0) {
|
if (currentCameraSetting < 0) {
|
||||||
if (cfg->color) currentCameraSetting=COLOR_BLUE;
|
if (cfg->color) {
|
||||||
else currentCameraSetting=BACKLIGHT;
|
currentCameraSetting = COLOR_BLUE;
|
||||||
|
} else {
|
||||||
|
currentCameraSetting = BACKLIGHT;
|
||||||
}
|
}
|
||||||
if ((!hasCameraSetting(currentCameraSetting)) || (getCameraSettingAuto(currentCameraSetting)))
|
}
|
||||||
|
if ((!hasCameraSetting(currentCameraSetting)) ||
|
||||||
|
(getCameraSettingAuto(currentCameraSetting)))
|
||||||
control(SETTING_PREVIOUS);
|
control(SETTING_PREVIOUS);
|
||||||
break;
|
break;
|
||||||
case SETTING_NEXT:
|
case SETTING_NEXT:
|
||||||
currentCameraSetting++;
|
currentCameraSetting++;
|
||||||
if ((cfg->color) && (currentCameraSetting>COLOR_BLUE)) currentCameraSetting=0;
|
if ((cfg->color) && (currentCameraSetting > COLOR_BLUE))
|
||||||
else if ((!cfg->color) && (currentCameraSetting>BACKLIGHT)) currentCameraSetting=0;
|
currentCameraSetting = 0;
|
||||||
if ((!hasCameraSetting(currentCameraSetting)) || (getCameraSettingAuto(currentCameraSetting)))
|
else if ((!cfg->color) && (currentCameraSetting > BACKLIGHT))
|
||||||
|
currentCameraSetting = 0;
|
||||||
|
if ((!hasCameraSetting(currentCameraSetting)) ||
|
||||||
|
(getCameraSettingAuto(currentCameraSetting)))
|
||||||
control(SETTING_NEXT);
|
control(SETTING_NEXT);
|
||||||
break;
|
break;
|
||||||
case KEY_D:
|
case KEY_D:
|
||||||
resetCameraSettings();
|
resetCameraSettings();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrl_val = getCameraSetting(currentCameraSetting);
|
ctrl_val = getCameraSetting(currentCameraSetting);
|
||||||
|
@ -124,8 +166,8 @@ void CameraEngine::control(unsigned char key) {
|
||||||
ctrl_min = getMinCameraSetting(currentCameraSetting);
|
ctrl_min = getMinCameraSetting(currentCameraSetting);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::uyvy2gray(int width, int height, unsigned char *src, unsigned char *dest) {
|
void CameraEngine::uyvy2gray(int width, int height,
|
||||||
|
unsigned char *src, unsigned char *dest) {
|
||||||
for (int i = height*width/2; i > 0; i--) {
|
for (int i = height*width/2; i > 0; i--) {
|
||||||
src++;
|
src++;
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
|
@ -134,7 +176,8 @@ void CameraEngine::uyvy2gray(int width, int height, unsigned char *src, unsigned
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::crop_uyvy2gray(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
|
void CameraEngine::crop_uyvy2gray(int cam_w,
|
||||||
|
unsigned char *cam_buf, unsigned char *frm_buf) {
|
||||||
|
|
||||||
if (!cfg->frame) return;
|
if (!cfg->frame) return;
|
||||||
int x_off = cfg->frame_xoff;
|
int x_off = cfg->frame_xoff;
|
||||||
|
@ -146,7 +189,6 @@ void CameraEngine::crop_uyvy2gray(int cam_w, unsigned char *cam_buf, unsigned ch
|
||||||
int x_end = cam_w-(frm_w+x_off);
|
int x_end = cam_w-(frm_w+x_off);
|
||||||
|
|
||||||
for (int i = frm_h; i > 0; i--) {
|
for (int i = frm_h; i > 0; i--) {
|
||||||
|
|
||||||
cam_buf += 2*x_off;
|
cam_buf += 2*x_off;
|
||||||
for (int j = frm_w/2; j > 0; j--) {
|
for (int j = frm_w/2; j > 0; j--) {
|
||||||
cam_buf++;
|
cam_buf++;
|
||||||
|
@ -158,7 +200,8 @@ void CameraEngine::crop_uyvy2gray(int cam_w, unsigned char *cam_buf, unsigned ch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::yuyv2gray(int width, int height, unsigned char *src, unsigned char *dest) {
|
void CameraEngine::yuyv2gray(int width, int height,
|
||||||
|
unsigned char *src, unsigned char *dest) {
|
||||||
for (int i = height*width/2; i > 0; i--) {
|
for (int i = height*width/2; i > 0; i--) {
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
src++;
|
src++;
|
||||||
|
@ -167,8 +210,8 @@ void CameraEngine::yuyv2gray(int width, int height, unsigned char *src, unsigned
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::crop_yuyv2gray(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
|
void CameraEngine::crop_yuyv2gray(int cam_w,
|
||||||
|
unsigned char *cam_buf, unsigned char *frm_buf) {
|
||||||
if (!cfg->frame) return;
|
if (!cfg->frame) return;
|
||||||
int x_off = cfg->frame_xoff;
|
int x_off = cfg->frame_xoff;
|
||||||
int y_off = cfg->frame_yoff;
|
int y_off = cfg->frame_yoff;
|
||||||
|
@ -179,7 +222,6 @@ void CameraEngine::crop_yuyv2gray(int cam_w, unsigned char *cam_buf, unsigned ch
|
||||||
int x_end = cam_w-(frm_w+x_off);
|
int x_end = cam_w-(frm_w+x_off);
|
||||||
|
|
||||||
for (int i = frm_h; i > 0; i--) {
|
for (int i = frm_h; i > 0; i--) {
|
||||||
|
|
||||||
cam_buf += 2*x_off;
|
cam_buf += 2*x_off;
|
||||||
for (int j = frm_w/2; j > 0; j--) {
|
for (int j = frm_w/2; j > 0; j--) {
|
||||||
*frm_buf++ = *cam_buf++;
|
*frm_buf++ = *cam_buf++;
|
||||||
|
@ -193,7 +235,6 @@ void CameraEngine::crop_yuyv2gray(int cam_w, unsigned char *cam_buf, unsigned ch
|
||||||
|
|
||||||
// void yuv2rgb_conv(int Y1, int Y2, int U, int V, unsigned char *dest) {
|
// void yuv2rgb_conv(int Y1, int Y2, int U, int V, unsigned char *dest) {
|
||||||
void yuv2rgb_conv(int Y, int U, int V, unsigned char *dest) {
|
void yuv2rgb_conv(int Y, int U, int V, unsigned char *dest) {
|
||||||
|
|
||||||
/*int R = (int)(Y + 1.370705f * V);
|
/*int R = (int)(Y + 1.370705f * V);
|
||||||
int G = (int)(Y - 0.698001f * V - 0.337633f * U);
|
int G = (int)(Y - 0.698001f * V - 0.337633f * U);
|
||||||
int B = (int)(Y + 1.732446f * U);*/
|
int B = (int)(Y + 1.732446f * U);*/
|
||||||
|
@ -213,8 +254,8 @@ void yuv2rgb_conv(int Y, int U, int V, unsigned char *dest) {
|
||||||
*dest++ = B;
|
*dest++ = B;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::uyvy2rgb(int width, int height, unsigned char *src, unsigned char *dest) {
|
void CameraEngine::uyvy2rgb(int width, int height, unsigned char *src,
|
||||||
|
unsigned char *dest) {
|
||||||
int Y1, Y2, U, V;
|
int Y1, Y2, U, V;
|
||||||
|
|
||||||
for (int i = width*height/2; i > 0; i--) {
|
for (int i = width*height/2; i > 0; i--) {
|
||||||
|
@ -230,8 +271,8 @@ void CameraEngine::uyvy2rgb(int width, int height, unsigned char *src, unsigned
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::crop_uyvy2rgb(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
|
void CameraEngine::crop_uyvy2rgb(int cam_w, unsigned char *cam_buf,
|
||||||
|
unsigned char *frm_buf) {
|
||||||
if (!cfg->frame) return;
|
if (!cfg->frame) return;
|
||||||
int x_off = cfg->frame_xoff;
|
int x_off = cfg->frame_xoff;
|
||||||
int y_off = cfg->frame_yoff;
|
int y_off = cfg->frame_yoff;
|
||||||
|
@ -244,7 +285,6 @@ void CameraEngine::crop_uyvy2rgb(int cam_w, unsigned char *cam_buf, unsigned cha
|
||||||
int x_end = cam_w-(frm_w+x_off);
|
int x_end = cam_w-(frm_w+x_off);
|
||||||
|
|
||||||
for (int i = frm_h; i > 0; i--) {
|
for (int i = frm_h; i > 0; i--) {
|
||||||
|
|
||||||
cam_buf += 2*x_off;
|
cam_buf += 2*x_off;
|
||||||
for (int j=frm_w/2; j > 0; j--) {
|
for (int j=frm_w/2; j > 0; j--) {
|
||||||
// U and V are +-0.5
|
// U and V are +-0.5
|
||||||
|
@ -261,12 +301,10 @@ void CameraEngine::crop_uyvy2rgb(int cam_w, unsigned char *cam_buf, unsigned cha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::yuyv2rgb(int width, int height, unsigned char *src, unsigned char *dest) {
|
void CameraEngine::yuyv2rgb(int width, int height, unsigned char *src,
|
||||||
|
unsigned char *dest) {
|
||||||
int Y1, Y2, U, V;
|
int Y1, Y2, U, V;
|
||||||
|
|
||||||
for (int i = width*height/2; i > 0; i--) {
|
for (int i = width*height/2; i > 0; i--) {
|
||||||
|
|
||||||
Y1 = *src++;
|
Y1 = *src++;
|
||||||
U = *src++ - 128;
|
U = *src++ - 128;
|
||||||
Y2 = *src++;
|
Y2 = *src++;
|
||||||
|
@ -278,8 +316,8 @@ void CameraEngine::yuyv2rgb(int width, int height, unsigned char *src, unsigned
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::crop_yuyv2rgb(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
|
void CameraEngine::crop_yuyv2rgb(int cam_w,
|
||||||
|
unsigned char *cam_buf, unsigned char *frm_buf) {
|
||||||
if (!cfg->frame) return;
|
if (!cfg->frame) return;
|
||||||
int x_off = cfg->frame_xoff;
|
int x_off = cfg->frame_xoff;
|
||||||
int y_off = cfg->frame_yoff;
|
int y_off = cfg->frame_yoff;
|
||||||
|
@ -292,7 +330,6 @@ void CameraEngine::crop_yuyv2rgb(int cam_w, unsigned char *cam_buf, unsigned cha
|
||||||
int x_end = cam_w-(frm_w+x_off);
|
int x_end = cam_w-(frm_w+x_off);
|
||||||
|
|
||||||
for (int i = frm_h; i > 0; i--) {
|
for (int i = frm_h; i > 0; i--) {
|
||||||
|
|
||||||
cam_buf += 2*x_off;
|
cam_buf += 2*x_off;
|
||||||
for (int j=frm_w/2; j > 0; j--) {
|
for (int j=frm_w/2; j > 0; j--) {
|
||||||
// U and V are +-0.5
|
// U and V are +-0.5
|
||||||
|
@ -309,8 +346,8 @@ void CameraEngine::crop_yuyv2rgb(int cam_w, unsigned char *cam_buf, unsigned cha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::gray2rgb(int width, int height, unsigned char *src, unsigned char *dest) {
|
void CameraEngine::gray2rgb(int width, int height, unsigned char *src,
|
||||||
|
unsigned char *dest) {
|
||||||
int size = width*height;
|
int size = width*height;
|
||||||
for (int i=size; i > 0; i--) {
|
for (int i=size; i > 0; i--) {
|
||||||
unsigned char pixel = *src++;
|
unsigned char pixel = *src++;
|
||||||
|
@ -320,8 +357,8 @@ void CameraEngine::gray2rgb(int width, int height, unsigned char *src, unsigned
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::crop_gray2rgb(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
|
void CameraEngine::crop_gray2rgb(int cam_w, unsigned char *cam_buf,
|
||||||
|
unsigned char *frm_buf) {
|
||||||
if (!cfg->frame) return;
|
if (!cfg->frame) return;
|
||||||
int x_off = cfg->frame_xoff;
|
int x_off = cfg->frame_xoff;
|
||||||
int y_off = cfg->frame_yoff;
|
int y_off = cfg->frame_yoff;
|
||||||
|
@ -332,7 +369,6 @@ void CameraEngine::crop_gray2rgb(int cam_w, unsigned char *cam_buf, unsigned cha
|
||||||
int x_end = cam_w-(frm_w+x_off);
|
int x_end = cam_w-(frm_w+x_off);
|
||||||
|
|
||||||
for (int i = frm_h; i > 0; i--) {
|
for (int i = frm_h; i > 0; i--) {
|
||||||
|
|
||||||
cam_buf += x_off;
|
cam_buf += x_off;
|
||||||
for (int j = frm_w; j > 0; j--) {
|
for (int j = frm_w; j > 0; j--) {
|
||||||
unsigned char pixel = *cam_buf++;
|
unsigned char pixel = *cam_buf++;
|
||||||
|
@ -344,8 +380,9 @@ void CameraEngine::crop_gray2rgb(int cam_w, unsigned char *cam_buf, unsigned cha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::grayw2rgb(int width, int height, unsigned char *src, unsigned char *dest) {
|
void CameraEngine::grayw2rgb(int width, int height, unsigned char *src,
|
||||||
unsigned short src_pixel;
|
unsigned char *dest) {
|
||||||
|
unsigned short src_pixel; // NOLINT
|
||||||
unsigned char dest_pixel;
|
unsigned char dest_pixel;
|
||||||
unsigned char pixel;
|
unsigned char pixel;
|
||||||
|
|
||||||
|
@ -359,15 +396,15 @@ void CameraEngine::grayw2rgb(int width, int height, unsigned char *src, unsigned
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::crop_grayw2rgb(int cam_w, unsigned char *src, unsigned char *dest) {
|
void CameraEngine::crop_grayw2rgb(int cam_w, unsigned char *src,
|
||||||
|
unsigned char *dest) {
|
||||||
if (!cfg->frame) return;
|
if (!cfg->frame) return;
|
||||||
int x_off = cfg->frame_xoff;
|
int x_off = cfg->frame_xoff;
|
||||||
int y_off = cfg->frame_yoff;
|
int y_off = cfg->frame_yoff;
|
||||||
int frm_w = cfg->frame_width;
|
int frm_w = cfg->frame_width;
|
||||||
int frm_h = cfg->frame_height;
|
int frm_h = cfg->frame_height;
|
||||||
|
|
||||||
unsigned short src_pixel;
|
unsigned short src_pixel; // NOLINT
|
||||||
unsigned char dest_pixel;
|
unsigned char dest_pixel;
|
||||||
unsigned char pixel;
|
unsigned char pixel;
|
||||||
|
|
||||||
|
@ -375,7 +412,6 @@ void CameraEngine::crop_grayw2rgb(int cam_w, unsigned char *src, unsigned char *
|
||||||
int x_end = cam_w-(frm_w+x_off);
|
int x_end = cam_w-(frm_w+x_off);
|
||||||
|
|
||||||
for (int i=frm_h; i > 0; i--) {
|
for (int i=frm_h; i > 0; i--) {
|
||||||
|
|
||||||
src += 2*x_off;
|
src += 2*x_off;
|
||||||
for (int j=frm_w; j > 0; j--) {
|
for (int j=frm_w; j > 0; j--) {
|
||||||
pixel = *src++;
|
pixel = *src++;
|
||||||
|
@ -388,12 +424,11 @@ void CameraEngine::crop_grayw2rgb(int cam_w, unsigned char *src, unsigned char *
|
||||||
}
|
}
|
||||||
src += 2*x_end;
|
src += 2*x_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::grayw2gray(int width, int height, unsigned char *src, unsigned char *dest) {
|
void CameraEngine::grayw2gray(int width, int height, unsigned char *src,
|
||||||
|
unsigned char *dest) {
|
||||||
unsigned short value;
|
unsigned short value; // NOLINT
|
||||||
unsigned char pixel;
|
unsigned char pixel;
|
||||||
|
|
||||||
for (int i=width*height; i > 0; i--) {
|
for (int i=width*height; i > 0; i--) {
|
||||||
|
@ -403,22 +438,21 @@ void CameraEngine::grayw2gray(int width, int height, unsigned char *src, unsigne
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::crop_grayw2gray(int cam_w, unsigned char *src, unsigned char *dest) {
|
void CameraEngine::crop_grayw2gray(int cam_w, unsigned char *src,
|
||||||
|
unsigned char *dest) {
|
||||||
if (!cfg->frame) return;
|
if (!cfg->frame) return;
|
||||||
int x_off = cfg->frame_xoff;
|
int x_off = cfg->frame_xoff;
|
||||||
int y_off = cfg->frame_yoff;
|
int y_off = cfg->frame_yoff;
|
||||||
int frm_w = cfg->frame_width;
|
int frm_w = cfg->frame_width;
|
||||||
int frm_h = cfg->frame_height;
|
int frm_h = cfg->frame_height;
|
||||||
|
|
||||||
unsigned short src_pixel;
|
unsigned short src_pixel; // NOLINT
|
||||||
unsigned char pixel;
|
unsigned char pixel;
|
||||||
|
|
||||||
src += 2*y_off*cam_w;
|
src += 2*y_off*cam_w;
|
||||||
int x_end = cam_w-(frm_w+x_off);
|
int x_end = cam_w-(frm_w+x_off);
|
||||||
|
|
||||||
for (int i=frm_h; i > 0; i--) {
|
for (int i=frm_h; i > 0; i--) {
|
||||||
|
|
||||||
src += 2*x_off;
|
src += 2*x_off;
|
||||||
for (int j=frm_w; j > 0; j--) {
|
for (int j=frm_w; j > 0; j--) {
|
||||||
pixel = *src++;
|
pixel = *src++;
|
||||||
|
@ -429,8 +463,8 @@ void CameraEngine::crop_grayw2gray(int cam_w, unsigned char *src, unsigned char
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::crop(int cam_w, int cam_h, unsigned char *cam_buf, unsigned char *frm_buf, int b) {
|
void CameraEngine::crop(int cam_w, int cam_h, unsigned char *cam_buf,
|
||||||
|
unsigned char *frm_buf, int b) {
|
||||||
if (!cfg->frame) return;
|
if (!cfg->frame) return;
|
||||||
int x_off = cfg->frame_xoff;
|
int x_off = cfg->frame_xoff;
|
||||||
int y_off = cfg->frame_yoff;
|
int y_off = cfg->frame_yoff;
|
||||||
|
@ -447,8 +481,8 @@ void CameraEngine::crop(int cam_w, int cam_h, unsigned char *cam_buf, unsigned c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::flip(int width, int height, unsigned char *src, unsigned char *dest, int b) {
|
void CameraEngine::flip(int width, int height, unsigned char *src,
|
||||||
|
unsigned char *dest, int b) {
|
||||||
int size = b*width*height;
|
int size = b*width*height;
|
||||||
dest += size-1;
|
dest += size-1;
|
||||||
for (int i=size; i > 0; i--) {
|
for (int i=size; i > 0; i--) {
|
||||||
|
@ -456,8 +490,8 @@ void CameraEngine::flip(int width, int height, unsigned char *src, unsigned char
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::flip_crop(int cam_w, int cam_h, unsigned char *cam_buf, unsigned char *frm_buf, int b) {
|
void CameraEngine::flip_crop(int cam_w, int cam_h, unsigned char *cam_buf,
|
||||||
|
unsigned char *frm_buf, int b) {
|
||||||
if (!cfg->frame) return;
|
if (!cfg->frame) return;
|
||||||
int x_off = cfg->frame_xoff;
|
int x_off = cfg->frame_xoff;
|
||||||
int y_off = cfg->frame_yoff;
|
int y_off = cfg->frame_yoff;
|
||||||
|
@ -469,7 +503,6 @@ void CameraEngine::flip_crop(int cam_w, int cam_h, unsigned char *cam_buf, unsig
|
||||||
int xend = (cam_w-(frm_w+x_off));
|
int xend = (cam_w-(frm_w+x_off));
|
||||||
|
|
||||||
for (int i=frm_h; i > 0; i--) {
|
for (int i=frm_h; i > 0; i--) {
|
||||||
|
|
||||||
cam_buf += b*x_off;
|
cam_buf += b*x_off;
|
||||||
for (int j=b*frm_w; j > 0; j--) {
|
for (int j=b*frm_w; j > 0; j--) {
|
||||||
*frm_buf-- = *cam_buf++;
|
*frm_buf-- = *cam_buf++;
|
||||||
|
@ -478,11 +511,11 @@ void CameraEngine::flip_crop(int cam_w, int cam_h, unsigned char *cam_buf, unsig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::rgb2gray(int width, int height, unsigned char *src, unsigned char *dest) {
|
void CameraEngine::rgb2gray(int width, int height, unsigned char *src,
|
||||||
|
unsigned char *dest) {
|
||||||
|
|
||||||
int R, G, B;
|
int R, G, B;
|
||||||
for (int i=width*height; i > 0; i--) {
|
for (int i=width*height; i > 0; i--) {
|
||||||
|
|
||||||
R = *src++;
|
R = *src++;
|
||||||
G = *src++;
|
G = *src++;
|
||||||
B = *src++;
|
B = *src++;
|
||||||
|
@ -490,22 +523,22 @@ void CameraEngine::rgb2gray(int width, int height, unsigned char *src, unsigned
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::flip_rgb2gray(int width, int height, unsigned char *src, unsigned char *dest) {
|
void CameraEngine::flip_rgb2gray(int width, int height, unsigned char *src,
|
||||||
|
unsigned char *dest) {
|
||||||
|
|
||||||
int size = width*height;
|
int size = width*height;
|
||||||
dest += size-1;
|
dest += size-1;
|
||||||
|
|
||||||
int R, G, B;
|
int R, G, B;
|
||||||
for (int i = size; i > 0; i--) {
|
for (int i = size; i > 0; i--) {
|
||||||
|
|
||||||
R = *src++;
|
R = *src++;
|
||||||
G = *src++;
|
G = *src++;
|
||||||
B = *src++;
|
B = *src++;
|
||||||
*dest-- = HBT(R*77 + G*151 + B*28);
|
*dest-- = HBT(R*77 + G*151 + B*28);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void CameraEngine::crop_rgb2gray(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
|
void CameraEngine::crop_rgb2gray(int cam_w, unsigned char *cam_buf,
|
||||||
|
unsigned char *frm_buf) {
|
||||||
if (!cfg->frame) return;
|
if (!cfg->frame) return;
|
||||||
int x_off = cfg->frame_xoff;
|
int x_off = cfg->frame_xoff;
|
||||||
int y_off = cfg->frame_yoff;
|
int y_off = cfg->frame_yoff;
|
||||||
|
@ -517,7 +550,6 @@ void CameraEngine::crop_rgb2gray(int cam_w, unsigned char *cam_buf, unsigned cha
|
||||||
|
|
||||||
int R, G, B;
|
int R, G, B;
|
||||||
for (int i = frm_h; i > 0; i--) {
|
for (int i = frm_h; i > 0; i--) {
|
||||||
|
|
||||||
cam_buf += 3*x_off;
|
cam_buf += 3*x_off;
|
||||||
for (int j = frm_w; j > 0; j--) {
|
for (int j = frm_w; j > 0; j--) {
|
||||||
R = *cam_buf++;
|
R = *cam_buf++;
|
||||||
|
@ -529,8 +561,8 @@ void CameraEngine::crop_rgb2gray(int cam_w, unsigned char *cam_buf, unsigned cha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::flip_crop_rgb2gray(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
|
void CameraEngine::flip_crop_rgb2gray(int cam_w, unsigned char *cam_buf,
|
||||||
|
unsigned char *frm_buf) {
|
||||||
if (!cfg->frame) return;
|
if (!cfg->frame) return;
|
||||||
int x_off = cfg->frame_xoff;
|
int x_off = cfg->frame_xoff;
|
||||||
int y_off = cfg->frame_yoff;
|
int y_off = cfg->frame_yoff;
|
||||||
|
@ -543,7 +575,6 @@ void CameraEngine::flip_crop_rgb2gray(int cam_w, unsigned char *cam_buf, unsigne
|
||||||
|
|
||||||
int R, G, B;
|
int R, G, B;
|
||||||
for (int i = frm_h; i > 0; i--) {
|
for (int i = frm_h; i > 0; i--) {
|
||||||
|
|
||||||
cam_buf += 3*x_off;
|
cam_buf += 3*x_off;
|
||||||
for (int j = frm_w; j > 0; j--) {
|
for (int j = frm_w; j > 0; j--) {
|
||||||
R = *cam_buf++;
|
R = *cam_buf++;
|
||||||
|
@ -556,7 +587,6 @@ void CameraEngine::flip_crop_rgb2gray(int cam_w, unsigned char *cam_buf, unsigne
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::setupFrame() {
|
void CameraEngine::setupFrame() {
|
||||||
|
|
||||||
if (!cfg->frame) {
|
if (!cfg->frame) {
|
||||||
cfg->frame_width = cfg->cam_width;
|
cfg->frame_width = cfg->cam_width;
|
||||||
cfg->frame_height = cfg->cam_height;
|
cfg->frame_height = cfg->cam_height;
|
||||||
|
@ -574,8 +604,8 @@ void CameraEngine::setupFrame() {
|
||||||
if (cfg->frame_height > cfg->cam_height) cfg->frame_height = cfg->cam_height;
|
if (cfg->frame_height > cfg->cam_height) cfg->frame_height = cfg->cam_height;
|
||||||
|
|
||||||
// no cropping if same size
|
// no cropping if same size
|
||||||
if ((cfg->frame_width==cfg->cam_width) && (cfg->frame_height==cfg->cam_height)) {
|
if ((cfg->frame_width == cfg->cam_width) &&
|
||||||
|
(cfg->frame_height == cfg->cam_height)) {
|
||||||
cfg->frame_width = cfg->cam_width;
|
cfg->frame_width = cfg->cam_width;
|
||||||
cfg->frame_height = cfg->cam_height;
|
cfg->frame_height = cfg->cam_height;
|
||||||
cfg->frame = false;
|
cfg->frame = false;
|
||||||
|
@ -589,13 +619,10 @@ void CameraEngine::setupFrame() {
|
||||||
int ydiff = cfg->cam_height-cfg->frame_height;
|
int ydiff = cfg->cam_height-cfg->frame_height;
|
||||||
if (ydiff < 0) cfg->frame_yoff = 0;
|
if (ydiff < 0) cfg->frame_yoff = 0;
|
||||||
else if (cfg->frame_yoff > ydiff) cfg->frame_yoff = ydiff;
|
else if (cfg->frame_yoff > ydiff) cfg->frame_yoff = ydiff;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::applyCameraSetting(int mode, int value) {
|
void CameraEngine::applyCameraSetting(int mode, int value) {
|
||||||
|
|
||||||
if (!hasCameraSetting(mode)) return;
|
if (!hasCameraSetting(mode)) return;
|
||||||
|
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case SETTING_AUTO:
|
case SETTING_AUTO:
|
||||||
if (hasCameraSettingAuto(mode)) {
|
if (hasCameraSettingAuto(mode)) {
|
||||||
|
@ -608,10 +635,12 @@ void CameraEngine::applyCameraSetting(int mode, int value) {
|
||||||
return;
|
return;
|
||||||
case SETTING_MIN:
|
case SETTING_MIN:
|
||||||
setCameraSettingAuto(mode, false);
|
setCameraSettingAuto(mode, false);
|
||||||
setCameraSetting(mode,getMinCameraSetting(mode)); return;
|
setCameraSetting(mode, getMinCameraSetting(mode));
|
||||||
|
return;
|
||||||
case SETTING_MAX:
|
case SETTING_MAX:
|
||||||
setCameraSettingAuto(mode, false);
|
setCameraSettingAuto(mode, false);
|
||||||
setCameraSetting(mode,getMaxCameraSetting(mode)); return;
|
setCameraSetting(mode, getMaxCameraSetting(mode));
|
||||||
|
return;
|
||||||
default: {
|
default: {
|
||||||
int max = getMaxCameraSetting(mode);
|
int max = getMaxCameraSetting(mode);
|
||||||
int min = getMinCameraSetting(mode);
|
int min = getMinCameraSetting(mode);
|
||||||
|
@ -624,15 +653,12 @@ void CameraEngine::applyCameraSetting(int mode, int value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::resetCameraSettings() {
|
void CameraEngine::resetCameraSettings() {
|
||||||
|
|
||||||
for (int mode=MODE_MIN; mode <= MODE_MAX; mode++)
|
for (int mode=MODE_MIN; mode <= MODE_MAX; mode++)
|
||||||
setDefaultCameraSetting(mode);
|
setDefaultCameraSetting(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::applyCameraSettings() {
|
void CameraEngine::applyCameraSettings() {
|
||||||
|
|
||||||
resetCameraSettings();
|
resetCameraSettings();
|
||||||
|
|
||||||
applyCameraSetting(BRIGHTNESS, cfg->brightness);
|
applyCameraSetting(BRIGHTNESS, cfg->brightness);
|
||||||
applyCameraSetting(CONTRAST, cfg->contrast);
|
applyCameraSetting(CONTRAST, cfg->contrast);
|
||||||
applyCameraSetting(SHARPNESS, cfg->sharpness);
|
applyCameraSetting(SHARPNESS, cfg->sharpness);
|
||||||
|
@ -653,20 +679,16 @@ void CameraEngine::applyCameraSettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int CameraEngine::updateSetting(int mode) {
|
int CameraEngine::updateSetting(int mode) {
|
||||||
|
|
||||||
if (!hasCameraSetting(mode)) return SETTING_OFF;
|
if (!hasCameraSetting(mode)) return SETTING_OFF;
|
||||||
if (getCameraSettingAuto(mode)) return SETTING_AUTO;
|
if (getCameraSettingAuto(mode)) return SETTING_AUTO;
|
||||||
|
|
||||||
int value = getCameraSetting(mode);
|
int value = getCameraSetting(mode);
|
||||||
if (value == getDefaultCameraSetting(mode)) value = SETTING_DEFAULT;
|
if (value == getDefaultCameraSetting(mode)) value = SETTING_DEFAULT;
|
||||||
else if (value == getMinCameraSetting(mode)) value = SETTING_MIN;
|
else if (value == getMinCameraSetting(mode)) value = SETTING_MIN;
|
||||||
else if (value == getMaxCameraSetting(mode)) value = SETTING_MAX;
|
else if (value == getMaxCameraSetting(mode)) value = SETTING_MAX;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraEngine::updateSettings() {
|
void CameraEngine::updateSettings() {
|
||||||
|
|
||||||
cfg->brightness = updateSetting(BRIGHTNESS);
|
cfg->brightness = updateSetting(BRIGHTNESS);
|
||||||
cfg->contrast = updateSetting(CONTRAST);
|
cfg->contrast = updateSetting(CONTRAST);
|
||||||
cfg->sharpness = updateSetting(SHARPNESS);
|
cfg->sharpness = updateSetting(SHARPNESS);
|
||||||
|
@ -693,5 +715,4 @@ void CameraEngine::updateSettings() {
|
||||||
cfg->green = SETTING_OFF;
|
cfg->green = SETTING_OFF;
|
||||||
cfg->blue = SETTING_OFF;
|
cfg->blue = SETTING_OFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,21 +12,27 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef CAMERAENGINE_H
|
#ifndef SRC_MYNTEYE_UVC_MACOSX_CAMERAENGINE_H_
|
||||||
#define CAMERAENGINE_H
|
#define SRC_MYNTEYE_UVC_MACOSX_CAMERAENGINE_H_
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <CoreFoundation/CFBundle.h>
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
#include <limits.h>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include <CoreFoundation/CFBundle.h>
|
|
||||||
|
|
||||||
#define SAT(c) \
|
#define SAT(c) \
|
||||||
if (c & (~255)) { if (c < 0) c = 0; else c = 255; }
|
if (c & (~255)) { \
|
||||||
|
if (c < 0) { \
|
||||||
|
c = 0; \
|
||||||
|
} else { \
|
||||||
|
c = 255; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
#define HBT(x) (unsigned char)((x)>>8)
|
#define HBT(x) (unsigned char)((x)>>8)
|
||||||
|
|
||||||
#define KEY_A 4
|
#define KEY_A 4
|
||||||
|
@ -117,12 +123,32 @@ extern const char* dstr[];
|
||||||
#define SETTING_NEXT 81
|
#define SETTING_NEXT 81
|
||||||
#define SETTING_PREVIOUS 82
|
#define SETTING_PREVIOUS 82
|
||||||
|
|
||||||
enum CameraSetting { BRIGHTNESS, CONTRAST, SHARPNESS, AUTO_GAIN, GAIN, AUTO_EXPOSURE, EXPOSURE, SHUTTER, AUTO_FOCUS, FOCUS, AUTO_WHITE, WHITE, GAMMA, POWERLINE, BACKLIGHT, SATURATION, AUTO_HUE, COLOR_HUE, COLOR_RED, COLOR_GREEN, COLOR_BLUE };
|
enum CameraSetting {
|
||||||
|
BRIGHTNESS,
|
||||||
|
CONTRAST,
|
||||||
|
SHARPNESS,
|
||||||
|
AUTO_GAIN,
|
||||||
|
GAIN,
|
||||||
|
AUTO_EXPOSURE,
|
||||||
|
EXPOSURE,
|
||||||
|
SHUTTER,
|
||||||
|
AUTO_FOCUS,
|
||||||
|
FOCUS,
|
||||||
|
AUTO_WHITE,
|
||||||
|
WHITE,
|
||||||
|
GAMMA,
|
||||||
|
POWERLINE,
|
||||||
|
BACKLIGHT,
|
||||||
|
SATURATION,
|
||||||
|
AUTO_HUE,
|
||||||
|
COLOR_HUE,
|
||||||
|
COLOR_RED,
|
||||||
|
COLOR_GREEN,
|
||||||
|
COLOR_BLUE };
|
||||||
#define MODE_MIN BRIGHTNESS
|
#define MODE_MIN BRIGHTNESS
|
||||||
#define MODE_MAX COLOR_BLUE
|
#define MODE_MAX COLOR_BLUE
|
||||||
|
|
||||||
struct CameraConfig {
|
struct CameraConfig {
|
||||||
|
|
||||||
char path[256];
|
char path[256];
|
||||||
|
|
||||||
int driver;
|
int driver;
|
||||||
|
@ -166,37 +192,36 @@ struct CameraConfig {
|
||||||
int red;
|
int red;
|
||||||
int blue;
|
int blue;
|
||||||
int green;
|
int green;
|
||||||
|
|
||||||
bool force;
|
bool force;
|
||||||
|
|
||||||
bool operator < (const CameraConfig& c) const {
|
bool operator < (const CameraConfig& c) const {
|
||||||
|
|
||||||
// if (device < c.device) return true;
|
// if (device < c.device) return true;
|
||||||
// if (cam_format < c.cam_format) return true;
|
// if (cam_format < c.cam_format) return true;
|
||||||
|
|
||||||
if (cam_width > c.cam_width || (cam_width == c.cam_width && cam_height < c.cam_height))
|
if (cam_width > c.cam_width ||
|
||||||
|
(cam_width == c.cam_width && cam_height < c.cam_height))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (cam_width == c.cam_width && cam_height == c.cam_height) {
|
if (cam_width == c.cam_width && cam_height == c.cam_height) {
|
||||||
return (cam_fps > c.cam_fps);
|
return (cam_fps > c.cam_fps);
|
||||||
} else return false;
|
} else {return false;}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class CameraEngine
|
class CameraEngine {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
explicit CameraEngine(CameraConfig *cam_cfg) {
|
||||||
CameraEngine(CameraConfig *cam_cfg) {
|
|
||||||
cfg = cam_cfg;
|
cfg = cam_cfg;
|
||||||
settingsDialog = false;
|
settingsDialog = false;
|
||||||
|
|
||||||
if (cfg->color) cfg->buf_format=FORMAT_RGB;
|
if (cfg->color) {
|
||||||
else cfg->buf_format=FORMAT_GRAY;
|
cfg->buf_format = FORMAT_RGB;
|
||||||
|
} else {
|
||||||
|
cfg->buf_format = FORMAT_GRAY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~CameraEngine() {};
|
virtual ~CameraEngine() {}
|
||||||
|
|
||||||
virtual bool initCamera() = 0;
|
virtual bool initCamera() = 0;
|
||||||
virtual bool startCamera() = 0;
|
virtual bool startCamera() = 0;
|
||||||
|
@ -207,7 +232,8 @@ public:
|
||||||
virtual bool stillRunning() = 0;
|
virtual bool stillRunning() = 0;
|
||||||
|
|
||||||
void printInfo();
|
void printInfo();
|
||||||
static void setMinMaxConfig(CameraConfig *cam_cfg, std::vector<CameraConfig> cfg_list);
|
static void setMinMaxConfig(CameraConfig *cam_cfg,
|
||||||
|
std::vector<CameraConfig> cfg_list);
|
||||||
|
|
||||||
virtual int getCameraSettingStep(int mode) = 0;
|
virtual int getCameraSettingStep(int mode) = 0;
|
||||||
virtual int getMinCameraSetting(int mode) = 0;
|
virtual int getMinCameraSetting(int mode) = 0;
|
||||||
|
@ -224,15 +250,14 @@ public:
|
||||||
virtual bool showSettingsDialog(bool lock);
|
virtual bool showSettingsDialog(bool lock);
|
||||||
virtual void control(unsigned char key);
|
virtual void control(unsigned char key);
|
||||||
|
|
||||||
int getId() { return cfg->device; }
|
inline int getId() { return cfg->device; }
|
||||||
int getFps() { return (int)floor(cfg->cam_fps+0.5f); }
|
inline int getFps() { return static_cast<int>(floor(cfg->cam_fps+0.5f)); }
|
||||||
int getWidth() { return cfg->frame_width; }
|
inline int getWidth() { return cfg->frame_width; }
|
||||||
int getHeight() { return cfg->frame_height; }
|
inline int getHeight() { return cfg->frame_height; }
|
||||||
int getFormat() { return cfg->buf_format; }
|
inline int getFormat() { return cfg->buf_format; }
|
||||||
char* getName() { return cfg->name; }
|
inline char* getName() { return cfg->name; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
CameraConfig *cfg;
|
CameraConfig *cfg;
|
||||||
|
|
||||||
unsigned char* frm_buffer;
|
unsigned char* frm_buffer;
|
||||||
|
@ -244,18 +269,26 @@ protected:
|
||||||
bool settingsDialog;
|
bool settingsDialog;
|
||||||
int currentCameraSetting;
|
int currentCameraSetting;
|
||||||
|
|
||||||
void crop(int width, int height, unsigned char *src, unsigned char *dest, int bytes);
|
void crop(int width, int height, unsigned char *src,
|
||||||
void flip(int width, int height, unsigned char *src, unsigned char *dest, int bytes);
|
unsigned char *dest, int bytes);
|
||||||
void flip_crop(int width, int height, unsigned char *src, unsigned char *dest, int bytes);
|
void flip(int width, int height, unsigned char *src,
|
||||||
|
unsigned char *dest, int bytes);
|
||||||
|
void flip_crop(int width, int height, unsigned char *src,
|
||||||
|
unsigned char *dest, int bytes);
|
||||||
|
|
||||||
void rgb2gray(int width, int height, unsigned char *src, unsigned char *dest);
|
void rgb2gray(int width, int height, unsigned char *src,
|
||||||
|
unsigned char *dest);
|
||||||
void crop_rgb2gray(int width, unsigned char *src, unsigned char *dest);
|
void crop_rgb2gray(int width, unsigned char *src, unsigned char *dest);
|
||||||
void flip_rgb2gray(int width, int height, unsigned char *src, unsigned char *dest);
|
void flip_rgb2gray(int width, int height, unsigned char *src,
|
||||||
void flip_crop_rgb2gray(int width, unsigned char *src, unsigned char *dest);
|
unsigned char *dest);
|
||||||
|
void flip_crop_rgb2gray(int width, unsigned char *src,
|
||||||
|
unsigned char *dest);
|
||||||
|
|
||||||
void uyvy2gray(int width, int height, unsigned char *src, unsigned char *dest);
|
void uyvy2gray(int width, int height, unsigned char *src,
|
||||||
|
unsigned char *dest);
|
||||||
void crop_uyvy2gray(int width, unsigned char *src, unsigned char *dest);
|
void crop_uyvy2gray(int width, unsigned char *src, unsigned char *dest);
|
||||||
void yuyv2gray(int width, int height, unsigned char *src, unsigned char *dest);
|
void yuyv2gray(int width, int height, unsigned char *src,
|
||||||
|
unsigned char *dest);
|
||||||
void crop_yuyv2gray(int width, unsigned char *src, unsigned char *dest);
|
void crop_yuyv2gray(int width, unsigned char *src, unsigned char *dest);
|
||||||
void yuv2gray(int width, int height, unsigned char *src, unsigned char *dest);
|
void yuv2gray(int width, int height, unsigned char *src, unsigned char *dest);
|
||||||
void crop_yuv2gray(int width, unsigned char *src, unsigned char *dest);
|
void crop_yuv2gray(int width, unsigned char *src, unsigned char *dest);
|
||||||
|
@ -267,9 +300,11 @@ protected:
|
||||||
void yuyv2rgb(int width, int height, unsigned char *src, unsigned char *dest);
|
void yuyv2rgb(int width, int height, unsigned char *src, unsigned char *dest);
|
||||||
void crop_yuyv2rgb(int width, unsigned char *src, unsigned char *dest);
|
void crop_yuyv2rgb(int width, unsigned char *src, unsigned char *dest);
|
||||||
|
|
||||||
void grayw2rgb(int width, int height, unsigned char *src, unsigned char *dest);
|
void grayw2rgb(int width, int height, unsigned char *src,
|
||||||
|
unsigned char *dest);
|
||||||
void crop_grayw2rgb(int width, unsigned char *src, unsigned char *dest);
|
void crop_grayw2rgb(int width, unsigned char *src, unsigned char *dest);
|
||||||
void grayw2gray(int width, int height, unsigned char *src, unsigned char *dest);
|
void grayw2gray(int width, int height, unsigned char *src,
|
||||||
|
unsigned char *dest);
|
||||||
void crop_grayw2gray(int width, unsigned char *src, unsigned char *dest);
|
void crop_grayw2gray(int width, unsigned char *src, unsigned char *dest);
|
||||||
|
|
||||||
void resetCameraSettings();
|
void resetCameraSettings();
|
||||||
|
@ -303,4 +338,4 @@ protected:
|
||||||
int ctrl_max;
|
int ctrl_max;
|
||||||
int ctrl_val;
|
int ctrl_val;
|
||||||
};
|
};
|
||||||
#endif
|
#endif // SRC_MYNTEYE_UVC_MACOSX_CAMERAENGINE_H_
|
||||||
|
|
Loading…
Reference in New Issue
Block a user