Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 1 | /* |
| 2 | * main.cpp - test |
| 3 | * |
| 4 | * Copyright (c) 2014 Intel Corporation |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | * |
| 18 | * Author: Wind Yuan <feng.yuan@intel.com> |
| 19 | */ |
| 20 | |
| 21 | #include "device_manager.h" |
| 22 | #include "atomisp_device.h" |
Sameer Kibey | 7b42929 | 2015-08-07 10:55:38 -0700 | [diff] [blame] | 23 | #include "uvc_device.h" |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 24 | #include "isp_controller.h" |
| 25 | #include "isp_image_processor.h" |
| 26 | #include "x3a_analyzer_simple.h" |
| 27 | #if HAVE_IA_AIQ |
| 28 | #include "x3a_analyzer_aiq.h" |
| 29 | #endif |
Wind Yuan | d442731 | 2015-02-11 16:09:00 +0800 | [diff] [blame] | 30 | #if HAVE_LIBCL |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 31 | #include "cl_3a_image_processor.h" |
wangfei | cf4c4e7 | 2015-05-25 17:11:41 +0800 | [diff] [blame] | 32 | #include "cl_csc_image_processor.h" |
Yinhang Liu | 81c44e0 | 2015-06-03 15:47:48 +0800 | [diff] [blame] | 33 | #include "cl_hdr_handler.h" |
| 34 | #include "cl_tnr_handler.h" |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 35 | #endif |
| 36 | #if HAVE_LIBDRM |
| 37 | #include "drm_display.h" |
Wind Yuan | d442731 | 2015-02-11 16:09:00 +0800 | [diff] [blame] | 38 | #endif |
Wind Yuan | e25ce3f | 2015-05-04 18:07:29 +0800 | [diff] [blame] | 39 | #include "analyzer_loader.h" |
Jia Meng | 66efecf | 2015-06-17 11:11:10 +0000 | [diff] [blame] | 40 | #include <base/xcam_3a_types.h> |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 41 | #include <unistd.h> |
| 42 | #include <signal.h> |
| 43 | #include <stdlib.h> |
ShincyTu | e521cf9 | 2015-03-27 15:13:51 +0800 | [diff] [blame] | 44 | #include <string> |
Yinhang Liu | 81c44e0 | 2015-06-03 15:47:48 +0800 | [diff] [blame] | 45 | #include <getopt.h> |
John Ye | ae9da73 | 2015-01-22 13:36:36 +0800 | [diff] [blame] | 46 | #include "test_common.h" |
| 47 | |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 48 | using namespace XCam; |
| 49 | |
ShincyTu | e521cf9 | 2015-03-27 15:13:51 +0800 | [diff] [blame] | 50 | static Mutex g_mutex; |
| 51 | static Cond g_cond; |
| 52 | static bool g_stop = false; |
| 53 | |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 54 | class MainDeviceManager |
| 55 | : public DeviceManager |
| 56 | { |
| 57 | public: |
| 58 | MainDeviceManager () |
| 59 | : _file (NULL) |
| 60 | , _save_file (false) |
| 61 | , _interval (1) |
| 62 | , _frame_count (0) |
ShincyTu | e521cf9 | 2015-03-27 15:13:51 +0800 | [diff] [blame] | 63 | , _frame_save (0) |
Wind Yuan | 683f866 | 2015-03-27 18:52:38 +0800 | [diff] [blame] | 64 | , _enable_display (false) |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 65 | { |
| 66 | #if HAVE_LIBDRM |
| 67 | _display = DrmDisplay::instance(); |
| 68 | #endif |
Wind Yuan | 9162580 | 2015-06-24 15:36:01 +0800 | [diff] [blame] | 69 | XCAM_OBJ_PROFILING_INIT; |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 70 | } |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 71 | |
| 72 | ~MainDeviceManager () { |
| 73 | close_file (); |
| 74 | } |
| 75 | |
| 76 | void enable_save_file (bool enable) { |
| 77 | _save_file = enable; |
| 78 | } |
| 79 | void set_interval (uint32_t inteval) { |
| 80 | _interval = inteval; |
| 81 | } |
ShincyTu | e521cf9 | 2015-03-27 15:13:51 +0800 | [diff] [blame] | 82 | void set_frame_save (uint32_t frame_save) { |
| 83 | _frame_save = frame_save; |
| 84 | } |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 85 | |
Wind Yuan | 683f866 | 2015-03-27 18:52:38 +0800 | [diff] [blame] | 86 | void enable_display(bool value) { |
| 87 | _enable_display = value; |
| 88 | } |
| 89 | |
wangfei | cf4c4e7 | 2015-05-25 17:11:41 +0800 | [diff] [blame] | 90 | void set_display_mode(DrmDisplayMode mode) { |
| 91 | _display->set_display_mode (mode); |
| 92 | } |
| 93 | |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 94 | protected: |
Wind Yuan | 73af393 | 2015-07-02 17:52:43 +0800 | [diff] [blame] | 95 | virtual void handle_message (const SmartPtr<XCamMessage> &msg); |
| 96 | virtual void handle_buffer (const SmartPtr<VideoBuffer> &buf); |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 97 | |
Wind Yuan | 73af393 | 2015-07-02 17:52:43 +0800 | [diff] [blame] | 98 | int display_buf (const SmartPtr<VideoBuffer> &buf); |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 99 | |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 100 | private: |
| 101 | void open_file (); |
| 102 | void close_file (); |
| 103 | |
| 104 | FILE *_file; |
| 105 | bool _save_file; |
| 106 | uint32_t _interval; |
| 107 | uint32_t _frame_count; |
ShincyTu | e521cf9 | 2015-03-27 15:13:51 +0800 | [diff] [blame] | 108 | uint32_t _frame_save; |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 109 | SmartPtr<DrmDisplay> _display; |
Wind Yuan | 683f866 | 2015-03-27 18:52:38 +0800 | [diff] [blame] | 110 | bool _enable_display; |
Wind Yuan | 9162580 | 2015-06-24 15:36:01 +0800 | [diff] [blame] | 111 | XCAM_OBJ_PROFILING_DEFINES; |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | void |
Wind Yuan | 73af393 | 2015-07-02 17:52:43 +0800 | [diff] [blame] | 115 | MainDeviceManager::handle_message (const SmartPtr<XCamMessage> &msg) |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 116 | { |
| 117 | XCAM_UNUSED (msg); |
| 118 | } |
| 119 | |
| 120 | void |
Wind Yuan | 73af393 | 2015-07-02 17:52:43 +0800 | [diff] [blame] | 121 | MainDeviceManager::handle_buffer (const SmartPtr<VideoBuffer> &buf) |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 122 | { |
Wind Yuan | 683f866 | 2015-03-27 18:52:38 +0800 | [diff] [blame] | 123 | FPS_CALCULATION (fps_buf, 30); |
| 124 | |
Wind Yuan | 9162580 | 2015-06-24 15:36:01 +0800 | [diff] [blame] | 125 | XCAM_OBJ_PROFILING_START; |
| 126 | |
Wind Yuan | 683f866 | 2015-03-27 18:52:38 +0800 | [diff] [blame] | 127 | if (_enable_display) |
| 128 | display_buf (buf); |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 129 | |
Wind Yuan | 9162580 | 2015-06-24 15:36:01 +0800 | [diff] [blame] | 130 | XCAM_OBJ_PROFILING_END("main_dev_manager_display", 30); |
| 131 | |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 132 | if (!_save_file) |
| 133 | return ; |
| 134 | |
| 135 | if ((_frame_count++ % _interval) != 0) |
| 136 | return; |
| 137 | |
ShincyTu | e521cf9 | 2015-03-27 15:13:51 +0800 | [diff] [blame] | 138 | if ((_frame_save != 0) && (_frame_count > _frame_save)) { |
| 139 | SmartLock locker (g_mutex); |
| 140 | g_stop = true; |
| 141 | g_cond.broadcast (); |
| 142 | return; |
| 143 | } |
| 144 | |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 145 | const VideoBufferInfo & frame_info = buf->get_video_info (); |
| 146 | uint8_t *frame = buf->map (); |
ShincyTu | 2808b59 | 2015-03-13 17:17:25 +0800 | [diff] [blame] | 147 | |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 148 | if (frame == NULL) |
| 149 | return; |
ShincyTu | 2808b59 | 2015-03-13 17:17:25 +0800 | [diff] [blame] | 150 | |
| 151 | uint32_t size = 0; |
| 152 | |
| 153 | switch(frame_info.format) { |
| 154 | case V4L2_PIX_FMT_NV12: // 420 |
| 155 | case V4L2_PIX_FMT_NV21: |
| 156 | size = XCAM_ALIGN_UP(frame_info.width, 2) * XCAM_ALIGN_UP(frame_info.height, 2) * 3 / 2; |
| 157 | break; |
| 158 | case V4L2_PIX_FMT_YUV422P: // 422 Planar |
| 159 | case V4L2_PIX_FMT_YUYV: // 422 |
| 160 | case V4L2_PIX_FMT_SBGGR10: |
| 161 | case V4L2_PIX_FMT_SGBRG10: |
| 162 | case V4L2_PIX_FMT_SGRBG10: |
| 163 | case V4L2_PIX_FMT_SRGGB10: |
ShincyTu | 1a4de9d | 2015-06-01 18:04:51 +0800 | [diff] [blame] | 164 | case V4L2_PIX_FMT_SBGGR12: |
| 165 | case V4L2_PIX_FMT_SGBRG12: |
| 166 | case V4L2_PIX_FMT_SGRBG12: |
| 167 | case V4L2_PIX_FMT_SRGGB12: |
ShincyTu | 2808b59 | 2015-03-13 17:17:25 +0800 | [diff] [blame] | 168 | size = XCAM_ALIGN_UP(frame_info.width, 2) * XCAM_ALIGN_UP(frame_info.height, 2) * 2; |
| 169 | break; |
| 170 | default: |
| 171 | XCAM_LOG_ERROR ( |
| 172 | "unknown v4l2 format(%s) in buffer handle", |
| 173 | xcam_fourcc_to_string (frame_info.format)); |
| 174 | return; |
| 175 | } |
| 176 | |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 177 | open_file (); |
Jia Meng | 6c9241d | 2015-06-12 11:08:45 +0000 | [diff] [blame] | 178 | |
| 179 | if (!_file) { |
| 180 | XCAM_LOG_ERROR ("open file failed"); |
| 181 | } |
| 182 | |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 183 | if (fwrite (frame, size, 1, _file) <= 0) { |
| 184 | XCAM_LOG_WARNING ("write frame failed."); |
| 185 | } |
| 186 | } |
| 187 | |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 188 | int |
Wind Yuan | 73af393 | 2015-07-02 17:52:43 +0800 | [diff] [blame] | 189 | MainDeviceManager::display_buf (const SmartPtr<VideoBuffer> &data) |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 190 | { |
| 191 | #if HAVE_LIBDRM |
| 192 | XCamReturn ret = XCAM_RETURN_NO_ERROR; |
Wind Yuan | 73af393 | 2015-07-02 17:52:43 +0800 | [diff] [blame] | 193 | SmartPtr<VideoBuffer> buf = data; |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 194 | const VideoBufferInfo & frame_info = buf->get_video_info (); |
| 195 | struct v4l2_rect rect = { 0, 0, (int)frame_info.width, (int)frame_info.height }; |
| 196 | |
| 197 | if (!_display->is_render_inited ()) { |
wangfei | 139ea7e | 2015-04-27 18:13:40 +0800 | [diff] [blame] | 198 | ret = _display->render_init (0, 0, 1920, 1080, frame_info.format, &rect); |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 199 | CHECK (ret, "display failed on render_init"); |
| 200 | } |
| 201 | ret = _display->render_setup_frame_buffer (buf); |
| 202 | CHECK (ret, "display failed on framebuf set"); |
| 203 | ret = _display->render_buffer (buf); |
| 204 | CHECK (ret, "display failed on rendering"); |
| 205 | #endif |
| 206 | return 0; |
| 207 | } |
| 208 | |
| 209 | |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 210 | void |
| 211 | MainDeviceManager::open_file () |
| 212 | { |
ShincyTu | e521cf9 | 2015-03-27 15:13:51 +0800 | [diff] [blame] | 213 | if ((_file) && (_frame_save == 0)) |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 214 | return; |
ShincyTu | e521cf9 | 2015-03-27 15:13:51 +0800 | [diff] [blame] | 215 | |
| 216 | std::string file_name = DEFAULT_SAVE_FILE_NAME; |
| 217 | |
| 218 | if (_frame_save != 0) { |
| 219 | file_name += std::to_string(_frame_count); |
| 220 | } |
| 221 | file_name += ".raw"; |
| 222 | |
| 223 | _file = fopen(file_name.c_str(), "wb"); |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | void |
| 227 | MainDeviceManager::close_file () |
| 228 | { |
| 229 | if (_file) |
| 230 | fclose (_file); |
| 231 | _file = NULL; |
| 232 | } |
| 233 | |
| 234 | #define V4L2_CAPTURE_MODE_STILL 0x2000 |
| 235 | #define V4L2_CAPTURE_MODE_VIDEO 0x4000 |
| 236 | #define V4L2_CAPTURE_MODE_PREVIEW 0x8000 |
| 237 | |
Wind Yuan | 26e9e21 | 2015-04-16 15:55:45 +0800 | [diff] [blame] | 238 | typedef enum { |
| 239 | AnalyzerTypeSimple = 0, |
| 240 | AnalyzerTypeAiq, |
Wind Yuan | e25ce3f | 2015-05-04 18:07:29 +0800 | [diff] [blame] | 241 | AnalyzerTypeDynamic, |
Jia Meng | 9724cfe | 2015-08-12 15:04:45 +0800 | [diff] [blame] | 242 | AnalyzerTypeHybrid, |
Wind Yuan | 26e9e21 | 2015-04-16 15:55:45 +0800 | [diff] [blame] | 243 | } AnalyzerType; |
| 244 | |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 245 | void dev_stop_handler(int sig) |
| 246 | { |
| 247 | XCAM_UNUSED (sig); |
| 248 | |
| 249 | SmartLock locker (g_mutex); |
| 250 | g_stop = true; |
| 251 | g_cond.broadcast (); |
| 252 | |
| 253 | //exit(0); |
| 254 | } |
| 255 | |
| 256 | void print_help (const char *bin_name) |
| 257 | { |
| 258 | printf ("Usage: %s [-a analyzer]\n" |
Yinhang Liu | 81c44e0 | 2015-06-03 15:47:48 +0800 | [diff] [blame] | 259 | "Configurations:\n" |
ShincyTu | e521cf9 | 2015-03-27 15:13:51 +0800 | [diff] [blame] | 260 | "\t -a analyzer specify a analyzer\n" |
Wind Yuan | e25ce3f | 2015-05-04 18:07:29 +0800 | [diff] [blame] | 261 | "\t select from [simple, aiq, dynamic], default is [simple]\n" |
ShincyTu | e521cf9 | 2015-03-27 15:13:51 +0800 | [diff] [blame] | 262 | "\t -m mem_type specify video memory type\n" |
| 263 | "\t mem_type select from [dma, mmap], default is [mmap]\n" |
| 264 | "\t -s save file to %s\n" |
| 265 | "\t -n interval save file on every [interval] frame\n" |
| 266 | "\t -c process image with cl kernel\n" |
| 267 | "\t -f pixel_fmt specify output pixel format\n" |
ShincyTu | 1a4de9d | 2015-06-01 18:04:51 +0800 | [diff] [blame] | 268 | "\t pixel_fmt select from [NV12, YUYV, BA10, RG12], default is [NV12]\n" |
ShincyTu | e521cf9 | 2015-03-27 15:13:51 +0800 | [diff] [blame] | 269 | "\t -d cap_mode specify capture mode\n" |
| 270 | "\t cap_mode select from [video, still], default is [video]\n" |
yaowang1 | a5f1212 | 2015-07-27 14:53:38 +0800 | [diff] [blame] | 271 | "\t -b brightness specify brightness level\n" |
| 272 | "\t brightness level select from [0, 256], default is [128]\n" |
ShincyTu | e521cf9 | 2015-03-27 15:13:51 +0800 | [diff] [blame] | 273 | "\t -i frame_save specify the frame count to save, default is 0 which means endless\n" |
wangfei | cf4c4e7 | 2015-05-25 17:11:41 +0800 | [diff] [blame] | 274 | "\t -p preview on local display\n" |
Sameer Kibey | 7b42929 | 2015-08-07 10:55:38 -0700 | [diff] [blame] | 275 | "\t --usb specify node for usb camera device, enables capture path through USB camera \n" |
| 276 | "\t specify [/dev/video4, /dev/video5] depending on which node USB camera is attached\n" |
wangfei | cf4c4e7 | 2015-05-25 17:11:41 +0800 | [diff] [blame] | 277 | "\t -e display_mode preview mode\n" |
| 278 | "\t select from [primary, overlay], default is [primary]\n" |
Jia Meng | 8f94a10 | 2015-08-11 16:24:19 +0800 | [diff] [blame] | 279 | "\t --sync set analyzer in sync mode\n" |
ShincyTu | e521cf9 | 2015-03-27 15:13:51 +0800 | [diff] [blame] | 280 | "\t -h help\n" |
Yinhang Liu | 81c44e0 | 2015-06-03 15:47:48 +0800 | [diff] [blame] | 281 | "CL features:\n" |
| 282 | "\t --hdr specify hdr type, default is hdr off\n" |
| 283 | "\t select from [rgb, lab]\n" |
| 284 | "\t --tnr specify temporal noise reduction type, default is tnr off\n" |
| 285 | "\t select from [rgb, yuv, both]\n" |
| 286 | "\t --tnr-level specify tnr level\n" |
Yinhang Liu | b92930c | 2015-06-23 16:26:35 +0800 | [diff] [blame] | 287 | "\t --bilateral enable bilateral noise reduction\n" |
Yinhang Liu | 81c44e0 | 2015-06-03 15:47:48 +0800 | [diff] [blame] | 288 | "\t --enable-snr enable simple noise reduction\n" |
Jia Meng | 66efecf | 2015-06-17 11:11:10 +0000 | [diff] [blame] | 289 | "\t --enable-ee enable YEENR\n" |
ShincyTu | 63e2c26 | 2015-06-26 10:52:51 +0800 | [diff] [blame] | 290 | "\t --enable-bnr enable bayer noise reduction\n" |
Yinhang Liu | e26b262 | 2015-07-21 18:32:36 +0800 | [diff] [blame] | 291 | "\t --enable-dpc enable defect pixel correction\n" |
yaowang1 | 6e05115 | 2015-08-14 13:49:03 +0800 | [diff] [blame^] | 292 | "\t --enable-tonemapping enable tonemapping\n" |
Yinhang Liu | e26b262 | 2015-07-21 18:32:36 +0800 | [diff] [blame] | 293 | "(e.g.: xxxx --hdr=xx --tnr=xx --tnr-level=xx --bilateral --enable-snr --enable-ee --enable-bnr --enable-dpc)\n\n" |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 294 | , bin_name |
| 295 | , DEFAULT_SAVE_FILE_NAME); |
| 296 | } |
| 297 | |
| 298 | int main (int argc, char *argv[]) |
| 299 | { |
| 300 | XCamReturn ret = XCAM_RETURN_NO_ERROR; |
| 301 | SmartPtr<MainDeviceManager> device_manager = new MainDeviceManager; |
| 302 | SmartPtr<V4l2Device> device; |
| 303 | SmartPtr<V4l2SubDevice> event_device; |
| 304 | SmartPtr<IspController> isp_controller; |
| 305 | SmartPtr<X3aAnalyzer> analyzer; |
Jia Meng | 9724cfe | 2015-08-12 15:04:45 +0800 | [diff] [blame] | 306 | SmartPtr<AnalyzerLoader> loader; |
| 307 | const char *path_of_3a; |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 308 | SmartPtr<ImageProcessor> isp_processor; |
wangfei | cf4c4e7 | 2015-05-25 17:11:41 +0800 | [diff] [blame] | 309 | SmartPtr<CLCscImageProcessor> cl_csc_proccessor; |
Wind Yuan | 26e9e21 | 2015-04-16 15:55:45 +0800 | [diff] [blame] | 310 | AnalyzerType analyzer_type = AnalyzerTypeSimple; |
wangfei | cf4c4e7 | 2015-05-25 17:11:41 +0800 | [diff] [blame] | 311 | DrmDisplayMode display_mode = DRM_DISPLAY_MODE_PRIMARY; |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 312 | #if HAVE_LIBDRM |
| 313 | SmartPtr<DrmDisplay> drm_disp = DrmDisplay::instance(); |
| 314 | #endif |
| 315 | |
Wind Yuan | d442731 | 2015-02-11 16:09:00 +0800 | [diff] [blame] | 316 | #if HAVE_LIBCL |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 317 | SmartPtr<CL3aImageProcessor> cl_processor; |
Wind Yuan | d442731 | 2015-02-11 16:09:00 +0800 | [diff] [blame] | 318 | #endif |
| 319 | bool have_cl_processor = false; |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 320 | bool need_display = false; |
Wind Yuan | d442731 | 2015-02-11 16:09:00 +0800 | [diff] [blame] | 321 | enum v4l2_memory v4l2_mem_type = V4L2_MEMORY_MMAP; |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 322 | const char *bin_name = argv[0]; |
| 323 | int opt; |
ShincyTu | 2808b59 | 2015-03-13 17:17:25 +0800 | [diff] [blame] | 324 | uint32_t capture_mode = V4L2_CAPTURE_MODE_VIDEO; |
| 325 | uint32_t pixel_format = V4L2_PIX_FMT_NV12; |
Yinhang Liu | 81c44e0 | 2015-06-03 15:47:48 +0800 | [diff] [blame] | 326 | uint32_t hdr_type = CL_HDR_DISABLE; |
| 327 | uint32_t tnr_type = CL_TNR_DISABLE; |
Jia Meng | 66efecf | 2015-06-17 11:11:10 +0000 | [diff] [blame] | 328 | uint32_t denoise_type = 0; |
Yinhang Liu | 81c44e0 | 2015-06-03 15:47:48 +0800 | [diff] [blame] | 329 | uint8_t tnr_level = 0; |
Yinhang Liu | e26b262 | 2015-07-21 18:32:36 +0800 | [diff] [blame] | 330 | bool dpc_type = false; |
yaowang1 | 6e05115 | 2015-08-14 13:49:03 +0800 | [diff] [blame^] | 331 | bool tonemapping_type = false; |
yaowang1 | a5f1212 | 2015-07-27 14:53:38 +0800 | [diff] [blame] | 332 | int32_t brightness_level = 128; |
Sameer Kibey | 7b42929 | 2015-08-07 10:55:38 -0700 | [diff] [blame] | 333 | bool have_usbcam = 0; |
| 334 | char* usb_device_name = NULL; |
Jia Meng | 8f94a10 | 2015-08-11 16:24:19 +0800 | [diff] [blame] | 335 | bool sync_mode = false; |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 336 | |
yaowang1 | a5f1212 | 2015-07-27 14:53:38 +0800 | [diff] [blame] | 337 | const char *short_opts = "sca:n:m:f:d:b:pi:e:h"; |
Yinhang Liu | 81c44e0 | 2015-06-03 15:47:48 +0800 | [diff] [blame] | 338 | const struct option long_opts[] = { |
| 339 | {"hdr", required_argument, NULL, 'H'}, |
| 340 | {"tnr", required_argument, NULL, 'T'}, |
| 341 | {"tnr-level", required_argument, NULL, 'L'}, |
Yinhang Liu | b92930c | 2015-06-23 16:26:35 +0800 | [diff] [blame] | 342 | {"bilateral", no_argument, NULL, 'I'}, |
Yinhang Liu | 81c44e0 | 2015-06-03 15:47:48 +0800 | [diff] [blame] | 343 | {"enable-snr", no_argument, NULL, 'S'}, |
Jia Meng | 66efecf | 2015-06-17 11:11:10 +0000 | [diff] [blame] | 344 | {"enable-ee", no_argument, NULL, 'E'}, |
ShincyTu | 63e2c26 | 2015-06-26 10:52:51 +0800 | [diff] [blame] | 345 | {"enable-bnr", no_argument, NULL, 'B'}, |
Yinhang Liu | e26b262 | 2015-07-21 18:32:36 +0800 | [diff] [blame] | 346 | {"enable-dpc", no_argument, NULL, 'D'}, |
yaowang1 | 6e05115 | 2015-08-14 13:49:03 +0800 | [diff] [blame^] | 347 | {"enable-tonemapping", no_argument, NULL, 'M'}, |
Sameer Kibey | 7b42929 | 2015-08-07 10:55:38 -0700 | [diff] [blame] | 348 | {"usb", required_argument, NULL, 'U'}, |
Jia Meng | 8f94a10 | 2015-08-11 16:24:19 +0800 | [diff] [blame] | 349 | {"sync", no_argument, NULL, 'Y'}, |
Yinhang Liu | 81c44e0 | 2015-06-03 15:47:48 +0800 | [diff] [blame] | 350 | {0, 0, 0, 0}, |
| 351 | }; |
| 352 | |
| 353 | while ((opt = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) { |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 354 | switch (opt) { |
| 355 | case 'a': { |
Wind Yuan | e25ce3f | 2015-05-04 18:07:29 +0800 | [diff] [blame] | 356 | if (!strcmp (optarg, "dynamic")) |
| 357 | analyzer_type = AnalyzerTypeDynamic; |
| 358 | else if (!strcmp (optarg, "simple")) |
Wind Yuan | 26e9e21 | 2015-04-16 15:55:45 +0800 | [diff] [blame] | 359 | analyzer_type = AnalyzerTypeSimple; |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 360 | #if HAVE_IA_AIQ |
| 361 | else if (!strcmp (optarg, "aiq")) |
Wind Yuan | 26e9e21 | 2015-04-16 15:55:45 +0800 | [diff] [blame] | 362 | analyzer_type = AnalyzerTypeAiq; |
Jia Meng | 9724cfe | 2015-08-12 15:04:45 +0800 | [diff] [blame] | 363 | else if (!strcmp (optarg, "hybrid")) |
| 364 | analyzer_type = AnalyzerTypeHybrid; |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 365 | #endif |
| 366 | else { |
| 367 | print_help (bin_name); |
| 368 | return -1; |
| 369 | } |
| 370 | break; |
| 371 | } |
| 372 | |
Wind Yuan | d442731 | 2015-02-11 16:09:00 +0800 | [diff] [blame] | 373 | case 'm': { |
| 374 | if (!strcmp (optarg, "dma")) |
| 375 | v4l2_mem_type = V4L2_MEMORY_DMABUF; |
| 376 | else if (!strcmp (optarg, "mmap")) |
| 377 | v4l2_mem_type = V4L2_MEMORY_MMAP; |
| 378 | else |
| 379 | print_help (bin_name); |
| 380 | break; |
| 381 | } |
| 382 | |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 383 | case 's': |
| 384 | device_manager->enable_save_file (true); |
| 385 | break; |
| 386 | case 'n': |
| 387 | device_manager->set_interval (atoi(optarg)); |
| 388 | break; |
Wind Yuan | d442731 | 2015-02-11 16:09:00 +0800 | [diff] [blame] | 389 | case 'c': |
| 390 | have_cl_processor = true; |
| 391 | break; |
ShincyTu | 2808b59 | 2015-03-13 17:17:25 +0800 | [diff] [blame] | 392 | case 'f': |
ShincyTu | c846640 | 2015-03-31 11:03:39 +0800 | [diff] [blame] | 393 | CHECK_EXP ((strlen(optarg) == 4), "invalid pixel format\n"); |
| 394 | pixel_format = v4l2_fourcc ((unsigned)optarg[0], |
| 395 | (unsigned)optarg[1], |
| 396 | (unsigned)optarg[2], |
| 397 | (unsigned)optarg[3]); |
ShincyTu | 2808b59 | 2015-03-13 17:17:25 +0800 | [diff] [blame] | 398 | break; |
| 399 | case 'd': |
| 400 | if (!strcmp (optarg, "still")) |
| 401 | capture_mode = V4L2_CAPTURE_MODE_STILL; |
| 402 | else if (!strcmp (optarg, "video")) |
| 403 | capture_mode = V4L2_CAPTURE_MODE_VIDEO; |
| 404 | else { |
| 405 | print_help (bin_name); |
| 406 | return -1; |
| 407 | } |
| 408 | break; |
yaowang1 | a5f1212 | 2015-07-27 14:53:38 +0800 | [diff] [blame] | 409 | case 'b': |
| 410 | brightness_level = atoi(optarg); |
| 411 | if(brightness_level < 0 || brightness_level > 256) { |
| 412 | print_help (bin_name); |
| 413 | return -1; |
| 414 | } |
| 415 | break; |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 416 | case 'p': |
| 417 | need_display = true; |
| 418 | break; |
Sameer Kibey | 7b42929 | 2015-08-07 10:55:38 -0700 | [diff] [blame] | 419 | case 'U': |
| 420 | have_usbcam = true; |
| 421 | usb_device_name = strdup(optarg); |
| 422 | XCAM_LOG_DEBUG("using USB camera plugged in at node: %s", usb_device_name); |
| 423 | break; |
wangfei | cf4c4e7 | 2015-05-25 17:11:41 +0800 | [diff] [blame] | 424 | case 'e': { |
| 425 | if (!strcmp (optarg, "primary")) |
| 426 | display_mode = DRM_DISPLAY_MODE_PRIMARY; |
| 427 | else if (!strcmp (optarg, "overlay")) |
| 428 | display_mode = DRM_DISPLAY_MODE_OVERLAY; |
| 429 | else { |
| 430 | print_help (bin_name); |
| 431 | return -1; |
| 432 | } |
| 433 | break; |
| 434 | } |
ShincyTu | e521cf9 | 2015-03-27 15:13:51 +0800 | [diff] [blame] | 435 | case 'i': |
| 436 | device_manager->set_frame_save(atoi(optarg)); |
| 437 | break; |
Jia Meng | 8f94a10 | 2015-08-11 16:24:19 +0800 | [diff] [blame] | 438 | case 'Y': |
| 439 | sync_mode = true; |
| 440 | break; |
Yinhang Liu | 81c44e0 | 2015-06-03 15:47:48 +0800 | [diff] [blame] | 441 | case 'H': { |
| 442 | if (!strcasecmp (optarg, "rgb")) |
| 443 | hdr_type = CL_HDR_TYPE_RGB; |
| 444 | else if (!strcasecmp (optarg, "lab")) |
| 445 | hdr_type = CL_HDR_TYPE_LAB; |
| 446 | else { |
| 447 | print_help (bin_name); |
| 448 | return -1; |
| 449 | } |
| 450 | break; |
| 451 | } |
Yinhang Liu | b92930c | 2015-06-23 16:26:35 +0800 | [diff] [blame] | 452 | case 'I': { |
Jia Meng | 66efecf | 2015-06-17 11:11:10 +0000 | [diff] [blame] | 453 | denoise_type |= XCAM_DENOISE_TYPE_BILATERAL; |
Yinhang Liu | 81c44e0 | 2015-06-03 15:47:48 +0800 | [diff] [blame] | 454 | break; |
| 455 | } |
| 456 | case 'S': { |
Jia Meng | 66efecf | 2015-06-17 11:11:10 +0000 | [diff] [blame] | 457 | denoise_type |= XCAM_DENOISE_TYPE_SIMPLE; |
| 458 | break; |
| 459 | } |
| 460 | case 'E': { |
| 461 | denoise_type |= XCAM_DENOISE_TYPE_EE; |
Yinhang Liu | 81c44e0 | 2015-06-03 15:47:48 +0800 | [diff] [blame] | 462 | break; |
| 463 | } |
ShincyTu | 63e2c26 | 2015-06-26 10:52:51 +0800 | [diff] [blame] | 464 | case 'B': { |
| 465 | denoise_type |= XCAM_DENOISE_TYPE_BNR; |
| 466 | break; |
| 467 | } |
Yinhang Liu | e26b262 | 2015-07-21 18:32:36 +0800 | [diff] [blame] | 468 | case 'D': { |
| 469 | dpc_type = true; |
| 470 | break; |
| 471 | } |
Yinhang Liu | 81c44e0 | 2015-06-03 15:47:48 +0800 | [diff] [blame] | 472 | case 'T': { |
| 473 | if (!strcasecmp (optarg, "yuv")) |
| 474 | tnr_type = CL_TNR_TYPE_YUV; |
| 475 | else if (!strcasecmp (optarg, "rgb")) |
| 476 | tnr_type = CL_TNR_TYPE_RGB; |
| 477 | else if (!strcasecmp (optarg, "both")) |
| 478 | tnr_type = CL_TNR_TYPE_YUV | CL_TNR_TYPE_RGB; |
| 479 | else { |
| 480 | print_help (bin_name); |
| 481 | return -1; |
| 482 | } |
| 483 | break; |
| 484 | } |
| 485 | case 'L': { |
| 486 | if (atoi(optarg) < 0 || atoi(optarg) > 255) { |
| 487 | print_help (bin_name); |
| 488 | return -1; |
| 489 | } |
| 490 | tnr_level = atoi(optarg); |
| 491 | break; |
| 492 | } |
yaowang1 | 6e05115 | 2015-08-14 13:49:03 +0800 | [diff] [blame^] | 493 | case 'M': { |
| 494 | tonemapping_type = true; |
| 495 | break; |
| 496 | } |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 497 | case 'h': |
| 498 | print_help (bin_name); |
| 499 | return 0; |
| 500 | |
| 501 | default: |
| 502 | print_help (bin_name); |
| 503 | return -1; |
| 504 | } |
| 505 | } |
| 506 | |
wangfei | cf4c4e7 | 2015-05-25 17:11:41 +0800 | [diff] [blame] | 507 | if (need_display) { |
Wind Yuan | 683f866 | 2015-03-27 18:52:38 +0800 | [diff] [blame] | 508 | device_manager->enable_display (true); |
wangfei | cf4c4e7 | 2015-05-25 17:11:41 +0800 | [diff] [blame] | 509 | device_manager->set_display_mode (display_mode); |
| 510 | } |
ShincyTu | 2808b59 | 2015-03-13 17:17:25 +0800 | [diff] [blame] | 511 | if (!device.ptr ()) { |
Sameer Kibey | 7b42929 | 2015-08-07 10:55:38 -0700 | [diff] [blame] | 512 | if (have_usbcam) { |
| 513 | device = new UVCDevice (usb_device_name); |
| 514 | } else { |
| 515 | if (capture_mode == V4L2_CAPTURE_MODE_STILL) |
| 516 | device = new AtomispDevice (CAPTURE_DEVICE_STILL); |
| 517 | else if (capture_mode == V4L2_CAPTURE_MODE_VIDEO) |
| 518 | device = new AtomispDevice (CAPTURE_DEVICE_VIDEO); |
| 519 | else |
| 520 | device = new AtomispDevice (DEFAULT_CAPTURE_DEVICE); |
| 521 | } |
ShincyTu | 2808b59 | 2015-03-13 17:17:25 +0800 | [diff] [blame] | 522 | } |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 523 | if (!event_device.ptr ()) |
| 524 | event_device = new V4l2SubDevice (DEFAULT_EVENT_DEVICE); |
| 525 | if (!isp_controller.ptr ()) |
| 526 | isp_controller = new IspController (device); |
Wind Yuan | 26e9e21 | 2015-04-16 15:55:45 +0800 | [diff] [blame] | 527 | |
| 528 | switch (analyzer_type) { |
Wind Yuan | 3d1d15e | 2015-04-16 17:40:47 +0800 | [diff] [blame] | 529 | case AnalyzerTypeSimple: |
| 530 | analyzer = new X3aAnalyzerSimple (); |
| 531 | break; |
Wind Yuan | 26e9e21 | 2015-04-16 15:55:45 +0800 | [diff] [blame] | 532 | #if HAVE_IA_AIQ |
Wind Yuan | 3d1d15e | 2015-04-16 17:40:47 +0800 | [diff] [blame] | 533 | case AnalyzerTypeAiq: |
| 534 | analyzer = new X3aAnalyzerAiq (isp_controller, DEFAULT_CPF_FILE); |
| 535 | break; |
Jia Meng | 9724cfe | 2015-08-12 15:04:45 +0800 | [diff] [blame] | 536 | case AnalyzerTypeHybrid: { |
| 537 | path_of_3a = DEFAULT_DYNAMIC_3A_LIB; |
| 538 | loader = new AnalyzerLoader (path_of_3a); |
| 539 | analyzer = loader->load_hybrid_analyzer (loader, isp_controller, DEFAULT_CPF_FILE); |
| 540 | CHECK_EXP (analyzer.ptr (), "load hybrid 3a lib(%s) failed", path_of_3a); |
| 541 | break; |
| 542 | } |
Wind Yuan | 26e9e21 | 2015-04-16 15:55:45 +0800 | [diff] [blame] | 543 | #endif |
Wind Yuan | e25ce3f | 2015-05-04 18:07:29 +0800 | [diff] [blame] | 544 | case AnalyzerTypeDynamic: { |
Jia Meng | 9724cfe | 2015-08-12 15:04:45 +0800 | [diff] [blame] | 545 | path_of_3a = DEFAULT_DYNAMIC_3A_LIB; |
| 546 | loader = new AnalyzerLoader (path_of_3a); |
| 547 | analyzer = loader->load_dynamic_analyzer (loader); |
Wind Yuan | e25ce3f | 2015-05-04 18:07:29 +0800 | [diff] [blame] | 548 | CHECK_EXP (analyzer.ptr (), "load dynamic 3a lib(%s) failed", path_of_3a); |
| 549 | break; |
| 550 | } |
Wind Yuan | 3d1d15e | 2015-04-16 17:40:47 +0800 | [diff] [blame] | 551 | default: |
| 552 | print_help (bin_name); |
| 553 | return -1; |
Wind Yuan | 26e9e21 | 2015-04-16 15:55:45 +0800 | [diff] [blame] | 554 | } |
Jia Meng | 8f94a10 | 2015-08-11 16:24:19 +0800 | [diff] [blame] | 555 | XCAM_ASSERT (analyzer.ptr ()); |
| 556 | analyzer->set_sync_mode (sync_mode); |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 557 | |
| 558 | signal(SIGINT, dev_stop_handler); |
| 559 | |
| 560 | device->set_sensor_id (0); |
ShincyTu | 2808b59 | 2015-03-13 17:17:25 +0800 | [diff] [blame] | 561 | device->set_capture_mode (capture_mode); |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 562 | //device->set_mem_type (V4L2_MEMORY_DMABUF); |
Wind Yuan | d442731 | 2015-02-11 16:09:00 +0800 | [diff] [blame] | 563 | device->set_mem_type (v4l2_mem_type); |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 564 | device->set_buffer_count (8); |
ShincyTu | 1a4de9d | 2015-06-01 18:04:51 +0800 | [diff] [blame] | 565 | if (pixel_format == V4L2_PIX_FMT_SRGGB12) |
| 566 | device->set_framerate (30, 1); |
| 567 | else |
| 568 | device->set_framerate (25, 1); |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 569 | ret = device->open (); |
| 570 | CHECK (ret, "device(%s) open failed", device->get_device_name()); |
ShincyTu | 2808b59 | 2015-03-13 17:17:25 +0800 | [diff] [blame] | 571 | ret = device->set_format (1920, 1080, pixel_format, V4L2_FIELD_NONE, 1920 * 2); |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 572 | CHECK (ret, "device(%s) set format failed", device->get_device_name()); |
| 573 | |
| 574 | ret = event_device->open (); |
| 575 | CHECK (ret, "event device(%s) open failed", event_device->get_device_name()); |
| 576 | int event = V4L2_EVENT_ATOMISP_3A_STATS_READY; |
| 577 | ret = event_device->subscribe_event (event); |
| 578 | CHECK_CONTINUE ( |
| 579 | ret, |
| 580 | "device(%s) subscribe event(%d) failed", |
| 581 | event_device->get_device_name(), event); |
| 582 | event = V4L2_EVENT_FRAME_SYNC; |
| 583 | ret = event_device->subscribe_event (event); |
| 584 | CHECK_CONTINUE ( |
| 585 | ret, |
| 586 | "device(%s) subscribe event(%d) failed", |
| 587 | event_device->get_device_name(), event); |
| 588 | |
| 589 | device_manager->set_capture_device (device); |
| 590 | device_manager->set_event_device (event_device); |
| 591 | device_manager->set_isp_controller (isp_controller); |
| 592 | if (analyzer.ptr()) |
| 593 | device_manager->set_analyzer (analyzer); |
Wind Yuan | 3d1d15e | 2015-04-16 17:40:47 +0800 | [diff] [blame] | 594 | |
| 595 | if (have_cl_processor) |
| 596 | isp_processor = new IspExposureImageProcessor (isp_controller); |
| 597 | else |
| 598 | isp_processor = new IspImageProcessor (isp_controller); |
| 599 | |
| 600 | XCAM_ASSERT (isp_processor.ptr ()); |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 601 | device_manager->add_image_processor (isp_processor); |
wangfei | cf4c4e7 | 2015-05-25 17:11:41 +0800 | [diff] [blame] | 602 | if ((display_mode == DRM_DISPLAY_MODE_PRIMARY) && need_display && (!have_cl_processor)) { |
| 603 | cl_csc_proccessor = new CLCscImageProcessor(); |
| 604 | XCAM_ASSERT (cl_csc_proccessor.ptr ()); |
| 605 | device_manager->add_image_processor (cl_csc_proccessor); |
| 606 | } |
Wind Yuan | 3d1d15e | 2015-04-16 17:40:47 +0800 | [diff] [blame] | 607 | |
Wind Yuan | d442731 | 2015-02-11 16:09:00 +0800 | [diff] [blame] | 608 | #if HAVE_LIBCL |
| 609 | if (have_cl_processor) { |
yaowang1 | a5f1212 | 2015-07-27 14:53:38 +0800 | [diff] [blame] | 610 | |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 611 | cl_processor = new CL3aImageProcessor (); |
Wind Yuan | 7ddf260 | 2015-04-14 18:49:45 +0800 | [diff] [blame] | 612 | cl_processor->set_stats_callback(device_manager); |
Yinhang Liu | e26b262 | 2015-07-21 18:32:36 +0800 | [diff] [blame] | 613 | cl_processor->set_dpc(dpc_type); |
Yinhang Liu | 81c44e0 | 2015-06-03 15:47:48 +0800 | [diff] [blame] | 614 | cl_processor->set_hdr (hdr_type); |
Jia Meng | 66efecf | 2015-06-17 11:11:10 +0000 | [diff] [blame] | 615 | cl_processor->set_denoise (denoise_type); |
yaowang1 | 6e05115 | 2015-08-14 13:49:03 +0800 | [diff] [blame^] | 616 | cl_processor->set_tonemapping(tonemapping_type); |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 617 | if (need_display) { |
| 618 | cl_processor->set_output_format (V4L2_PIX_FMT_XBGR32); |
| 619 | } |
Yinhang Liu | 81c44e0 | 2015-06-03 15:47:48 +0800 | [diff] [blame] | 620 | cl_processor->set_tnr (tnr_type, tnr_level); |
yaowang1 | a5f1212 | 2015-07-27 14:53:38 +0800 | [diff] [blame] | 621 | analyzer->set_parameter_brightness((brightness_level - 128) / 128.0); |
Wind Yuan | d442731 | 2015-02-11 16:09:00 +0800 | [diff] [blame] | 622 | device_manager->add_image_processor (cl_processor); |
| 623 | } |
| 624 | #endif |
Wind Yuan | e4ba0c9 | 2015-03-26 16:59:06 +0800 | [diff] [blame] | 625 | |
Wind Yuan | 75564b1 | 2015-01-15 06:51:15 -0500 | [diff] [blame] | 626 | ret = device_manager->start (); |
| 627 | CHECK (ret, "device manager start failed"); |
| 628 | |
| 629 | // wait for interruption |
| 630 | { |
| 631 | SmartLock locker (g_mutex); |
| 632 | while (!g_stop) |
| 633 | g_cond.wait (g_mutex); |
| 634 | } |
| 635 | |
| 636 | ret = device_manager->stop(); |
| 637 | CHECK_CONTINUE (ret, "device manager stop failed"); |
| 638 | device->close (); |
| 639 | event_device->close (); |
| 640 | |
| 641 | return 0; |
| 642 | } |