This is a mbed Client sample where ZXing is incorporated, and works on GR-PEACH and GR-LYCHEE.

Dependencies:   DisplayApp AsciiFont

Overview

This sample program shows how to use mbed Client together with ZXing which is an open-source, multi-format 1D/2D barcode image processing library. For more info on ZXing, please refer to https://github.com/zxing/zxing.

Required hardware

Application setup

  1. Select the connection type. For details, please refer to the following wiki:
    https://os.mbed.com/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/Connection-type.
  2. Set the client credentials. For details, please refer to the following wiki:
    https://os.mbed.com/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/Client-credentials.
  3. Change Ethernet settings. For details, please refer to the following wiki:
    https://developer.mbed.org/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/Ethernet-settings.
  4. Change Wifi settings. For details, please refer to the following wiki:
    https://os.mbed.com/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/Wifi-settings.
  5. Set up an IP address. (This step is optional.) For details, please refer to the following wiki:
    https://os.mbed.com/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/IP-address-setup.

Building the example

To build this example:

  1. Import this example onto mbed Compiler.
  2. Configure the example in accordance with Application setup.
  3. Compile the example on mbed Compiler and download the resultant binary file.
  4. Plug the Ethernet cable into GR-PEACH or GR-LYCHEE if you are using Ethernet mode.
  5. Plug the micro-USB cable into the OpenSDA port which lies on the next to the RESET button.
  6. Copy the binary previously downloaded to your PC to GR-PEACH or GR-LYCHEE to flash this example. When the copy is successfully completed, the board is ready to work.
  7. Press the RESET button on the board to run the example.
  8. For verification, please refer to the following wiki:
    https://developer.mbed.org/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/Monitoring-the-application.

Application resources

This example exposes four resources listed below:

  1. 3202/0/5700. Decode result of barcode data input from camera (GET).
  2. 3201/0/5850. Blink function, blinks LED when executed (POST).
  3. 3201/0/5853. Blink pattern, used by the blink function to determine how to blink. In the format of 1000:500:1000:500:1000:500 (PUT).
  4. 3201/0/5855. Blink color, used by the blink function. Any of red, green, blue, cyan, yellow and magenta is acceptable if you are using GR-PEACH board (PUT).
  5. 3201/0/5855. Blink color, used by the blink function. Any of green, yellow, orange and red is acceptable if you are using GR-LYCHEE board (PUT).

For more info on how to get notifications when resource 1 changes, or how to use resource 2, 3 and 4, please look at

Import programGR-PEACH_mbed-connector-ZXingSample-node

Node.js based Web Application for mbed Device Connector specific to GR-PEACH_mbed-os-client-ZXingSample

Committer:
1050186
Date:
Thu Dec 13 09:17:41 2018 +0000
Revision:
10:f7e8d2b608c3
Parent:
6:ea24d9271ff1
Delete unnecessary code.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 0:eb73febb2bba 1
<> 0:eb73febb2bba 2 #include "mbed.h"
1050186 6:ea24d9271ff1 3 #include "EasyAttach_CameraAndLCD.h"
<> 0:eb73febb2bba 4 #include "ImageReaderSource.h"
1050186 6:ea24d9271ff1 5 #include "AsciiFont.h"
<> 0:eb73febb2bba 6
<> 0:eb73febb2bba 7 /**** User Selection *********/
dkato 2:6ec5c1c1d41c 8 /** JPEG out setting **/
1050186 6:ea24d9271ff1 9 #define JPEG_SEND (1) /* Select 0(JPEG images are not output to PC) or 1(JPEG images are output to PC on USB(CDC) for focusing the camera) */
1050186 6:ea24d9271ff1 10 #define JPEG_ENCODE_QUALITY (75) /* JPEG encode quality (min:1, max:75 (Considering the size of JpegBuffer, about 75 is the upper limit.)) */
1050186 6:ea24d9271ff1 11 #define VFIELD_INT_SKIP_CNT (0) /* A guide for GR-LYCHEE. 0:60fps, 1:30fps, 2:20fps, 3:15fps, 4:12fps, 5:10fps */
dkato 2:6ec5c1c1d41c 12 /** Decode hints **/
dkato 2:6ec5c1c1d41c 13 #define DECODE_HINTS (DecodeHints::ONED_HINT | DecodeHints::QR_CODE_HINT | DecodeHints::DATA_MATRIX_HINT | DecodeHints::AZTEC_HINT)
<> 0:eb73febb2bba 14 /*****************************/
<> 0:eb73febb2bba 15
1050186 6:ea24d9271ff1 16 /* Video input and LCD layer 0 output */
dkato 2:6ec5c1c1d41c 17 #define VIDEO_FORMAT (DisplayBase::VIDEO_FORMAT_YCBCR422)
dkato 2:6ec5c1c1d41c 18 #define GRAPHICS_FORMAT (DisplayBase::GRAPHICS_FORMAT_YCBCR422)
1050186 6:ea24d9271ff1 19 //#define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_32_16BIT)
dkato 2:6ec5c1c1d41c 20 #define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_16BIT)
1050186 6:ea24d9271ff1 21 #define DATA_SIZE_PER_PIC (2u)
<> 0:eb73febb2bba 22
<> 0:eb73febb2bba 23 /*! Frame buffer stride: Frame buffer stride should be set to a multiple of 32 or 128
<> 0:eb73febb2bba 24 in accordance with the frame buffer burst transfer mode. */
1050186 6:ea24d9271ff1 25 #if MBED_CONF_APP_LCD
1050186 6:ea24d9271ff1 26 #define VIDEO_PIXEL_HW LCD_PIXEL_WIDTH /* QVGA */
1050186 6:ea24d9271ff1 27 #define VIDEO_PIXEL_VW LCD_PIXEL_HEIGHT /* QVGA */
1050186 6:ea24d9271ff1 28 #else
1050186 6:ea24d9271ff1 29 #define VIDEO_PIXEL_HW (640u) /* VGA */
1050186 6:ea24d9271ff1 30 #define VIDEO_PIXEL_VW (480u) /* VGA */
1050186 6:ea24d9271ff1 31 #endif
<> 0:eb73febb2bba 32
1050186 6:ea24d9271ff1 33 #define FRAME_BUFFER_STRIDE (((VIDEO_PIXEL_HW * DATA_SIZE_PER_PIC) + 31u) & ~31u)
1050186 6:ea24d9271ff1 34 #define FRAME_BUFFER_HEIGHT (VIDEO_PIXEL_VW)
1050186 6:ea24d9271ff1 35
1050186 6:ea24d9271ff1 36 DisplayBase Display;
1050186 6:ea24d9271ff1 37 // Timer
<> 0:eb73febb2bba 38 static Timer decode_timer;
<> 0:eb73febb2bba 39
1050186 6:ea24d9271ff1 40 #if defined(__ICCARM__)
1050186 6:ea24d9271ff1 41 #pragma data_alignment=32
1050186 6:ea24d9271ff1 42 static uint8_t user_frame_buffer0[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]@ ".mirrorram";
1050186 6:ea24d9271ff1 43 #else
1050186 6:ea24d9271ff1 44 static uint8_t user_frame_buffer0[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]__attribute((section("NC_BSS"),aligned(32)));
1050186 6:ea24d9271ff1 45 #endif
1050186 6:ea24d9271ff1 46
1050186 6:ea24d9271ff1 47 #if JPEG_SEND
1050186 6:ea24d9271ff1 48 #include "JPEG_Converter.h"
1050186 6:ea24d9271ff1 49 #include "DisplayApp.h"
1050186 6:ea24d9271ff1 50 #include "dcache-control.h"
dkato 2:6ec5c1c1d41c 51
1050186 6:ea24d9271ff1 52 #if defined(__ICCARM__)
1050186 6:ea24d9271ff1 53 #pragma data_alignment=32
1050186 6:ea24d9271ff1 54 static uint8_t JpegBuffer[2][1024 * 64];
1050186 6:ea24d9271ff1 55 #else
1050186 6:ea24d9271ff1 56 static uint8_t JpegBuffer[2][1024 * 64]__attribute((aligned(32)));
1050186 6:ea24d9271ff1 57 #endif
1050186 6:ea24d9271ff1 58 static size_t jcu_encode_size[2];
1050186 6:ea24d9271ff1 59 static JPEG_Converter Jcu;
1050186 6:ea24d9271ff1 60 static int jcu_buf_index_write = 0;
1050186 6:ea24d9271ff1 61 static int jcu_buf_index_write_done = 0;
1050186 6:ea24d9271ff1 62 static int jcu_buf_index_read = 0;
1050186 6:ea24d9271ff1 63 static volatile int jcu_encoding = 0;
1050186 6:ea24d9271ff1 64 static volatile int image_change = 0;
1050186 6:ea24d9271ff1 65 static DisplayApp display_app;
1050186 6:ea24d9271ff1 66 static int Vfield_Int_Cnt = 0;
1050186 6:ea24d9271ff1 67
<> 0:eb73febb2bba 68 static int decode_wait_time = 0;
<> 0:eb73febb2bba 69 static void (*p_callback_func)(char * addr, int size);
<> 0:eb73febb2bba 70
1050186 6:ea24d9271ff1 71 static void JcuEncodeCallBackFunc(JPEG_Converter::jpeg_conv_error_t err_code) {
1050186 6:ea24d9271ff1 72 if (err_code == JPEG_Converter::JPEG_CONV_OK) {
1050186 6:ea24d9271ff1 73 jcu_buf_index_write_done = jcu_buf_index_write;
1050186 6:ea24d9271ff1 74 image_change = 1;
1050186 6:ea24d9271ff1 75 }
1050186 6:ea24d9271ff1 76 jcu_encoding = 0;
1050186 6:ea24d9271ff1 77 }
<> 0:eb73febb2bba 78
1050186 6:ea24d9271ff1 79 static void snapshot(void) {
1050186 6:ea24d9271ff1 80 while ((jcu_encoding == 1) || (image_change == 0)) {
1050186 6:ea24d9271ff1 81 Thread::wait(1);
<> 0:eb73febb2bba 82 }
1050186 6:ea24d9271ff1 83 jcu_buf_index_read = jcu_buf_index_write_done;
1050186 6:ea24d9271ff1 84 image_change = 0;
1050186 6:ea24d9271ff1 85 display_app.SendJpeg(JpegBuffer[jcu_buf_index_read], (int)jcu_encode_size[jcu_buf_index_read]);
<> 0:eb73febb2bba 86 }
<> 0:eb73febb2bba 87
1050186 6:ea24d9271ff1 88 static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type) {
1050186 6:ea24d9271ff1 89 if (Vfield_Int_Cnt < VFIELD_INT_SKIP_CNT) {
1050186 6:ea24d9271ff1 90 Vfield_Int_Cnt++;
1050186 6:ea24d9271ff1 91 return;
1050186 6:ea24d9271ff1 92 }
1050186 6:ea24d9271ff1 93 Vfield_Int_Cnt = 0;
1050186 6:ea24d9271ff1 94
1050186 6:ea24d9271ff1 95 //Interrupt callback function
1050186 6:ea24d9271ff1 96 if (jcu_encoding == 0) {
1050186 6:ea24d9271ff1 97 JPEG_Converter::bitmap_buff_info_t bitmap_buff_info;
1050186 6:ea24d9271ff1 98 JPEG_Converter::encode_options_t encode_options;
1050186 6:ea24d9271ff1 99
1050186 6:ea24d9271ff1 100 bitmap_buff_info.width = VIDEO_PIXEL_HW;
1050186 6:ea24d9271ff1 101 bitmap_buff_info.height = VIDEO_PIXEL_VW;
1050186 6:ea24d9271ff1 102 bitmap_buff_info.format = JPEG_Converter::WR_RD_YCbCr422;
1050186 6:ea24d9271ff1 103 bitmap_buff_info.buffer_address = (void *)user_frame_buffer0;
1050186 6:ea24d9271ff1 104
1050186 6:ea24d9271ff1 105 encode_options.encode_buff_size = sizeof(JpegBuffer[0]);
1050186 6:ea24d9271ff1 106 encode_options.p_EncodeCallBackFunc = &JcuEncodeCallBackFunc;
1050186 6:ea24d9271ff1 107 // encode_options.input_swapsetting = JPEG_Converter::WR_RD_WRSWA_32_16_8BIT;
1050186 6:ea24d9271ff1 108 encode_options.input_swapsetting = JPEG_Converter::WR_RD_WRSWA_16_8BIT;
1050186 6:ea24d9271ff1 109
1050186 6:ea24d9271ff1 110 jcu_encoding = 1;
1050186 6:ea24d9271ff1 111 if (jcu_buf_index_read == jcu_buf_index_write) {
1050186 6:ea24d9271ff1 112 jcu_buf_index_write ^= 1; // toggle
1050186 6:ea24d9271ff1 113 }
1050186 6:ea24d9271ff1 114 jcu_encode_size[jcu_buf_index_write] = 0;
1050186 6:ea24d9271ff1 115 dcache_invalid(JpegBuffer[jcu_buf_index_write], sizeof(JpegBuffer[0]));
1050186 6:ea24d9271ff1 116 if (Jcu.encode(&bitmap_buff_info, JpegBuffer[jcu_buf_index_write],
1050186 6:ea24d9271ff1 117 &jcu_encode_size[jcu_buf_index_write], &encode_options) != JPEG_Converter::JPEG_CONV_OK) {
1050186 6:ea24d9271ff1 118 jcu_encode_size[jcu_buf_index_write] = 0;
1050186 6:ea24d9271ff1 119 jcu_encoding = 0;
1050186 6:ea24d9271ff1 120 }
1050186 6:ea24d9271ff1 121 }
1050186 6:ea24d9271ff1 122 }
1050186 6:ea24d9271ff1 123 #endif
1050186 6:ea24d9271ff1 124
1050186 6:ea24d9271ff1 125 static void Start_Video_Camera(void) {
1050186 6:ea24d9271ff1 126 // Video capture setting (progressive form fixed)
1050186 6:ea24d9271ff1 127 Display.Video_Write_Setting(
1050186 6:ea24d9271ff1 128 DisplayBase::VIDEO_INPUT_CHANNEL_0,
1050186 6:ea24d9271ff1 129 DisplayBase::COL_SYS_NTSC_358,
1050186 6:ea24d9271ff1 130 (void *)user_frame_buffer0,
1050186 6:ea24d9271ff1 131 FRAME_BUFFER_STRIDE,
1050186 6:ea24d9271ff1 132 VIDEO_FORMAT,
1050186 6:ea24d9271ff1 133 WR_RD_WRSWA,
1050186 6:ea24d9271ff1 134 VIDEO_PIXEL_VW,
1050186 6:ea24d9271ff1 135 VIDEO_PIXEL_HW
1050186 6:ea24d9271ff1 136 );
1050186 6:ea24d9271ff1 137 EasyAttach_CameraStart(Display, DisplayBase::VIDEO_INPUT_CHANNEL_0);
1050186 6:ea24d9271ff1 138 }
1050186 6:ea24d9271ff1 139
1050186 6:ea24d9271ff1 140 #if MBED_CONF_APP_LCD
1050186 6:ea24d9271ff1 141 static void Start_LCD_Display(void) {
<> 0:eb73febb2bba 142 DisplayBase::rect_t rect;
<> 0:eb73febb2bba 143
<> 0:eb73febb2bba 144 rect.vs = 0;
1050186 6:ea24d9271ff1 145 rect.vw = LCD_PIXEL_HEIGHT;
<> 0:eb73febb2bba 146 rect.hs = 0;
1050186 6:ea24d9271ff1 147 rect.hw = LCD_PIXEL_WIDTH;
<> 0:eb73febb2bba 148 Display.Graphics_Read_Setting(
<> 0:eb73febb2bba 149 DisplayBase::GRAPHICS_LAYER_0,
1050186 6:ea24d9271ff1 150 (void *)user_frame_buffer0,
<> 0:eb73febb2bba 151 FRAME_BUFFER_STRIDE,
<> 0:eb73febb2bba 152 GRAPHICS_FORMAT,
<> 0:eb73febb2bba 153 WR_RD_WRSWA,
<> 0:eb73febb2bba 154 &rect
<> 0:eb73febb2bba 155 );
<> 0:eb73febb2bba 156 Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0);
1050186 6:ea24d9271ff1 157
1050186 6:ea24d9271ff1 158 Thread::wait(50);
1050186 6:ea24d9271ff1 159 EasyAttach_LcdBacklight(true);
<> 0:eb73febb2bba 160 }
dkato 2:6ec5c1c1d41c 161
dkato 2:6ec5c1c1d41c 162 #define VIDEO_PIXEL_HW_STR (VIDEO_PIXEL_HW - 64)
dkato 2:6ec5c1c1d41c 163 #define VIDEO_PIXEL_VW_STR (VIDEO_PIXEL_VW - 64)
dkato 2:6ec5c1c1d41c 164 #define FRAME_BUFFER_BYTE_PER_PIXEL_STR (2u)
dkato 2:6ec5c1c1d41c 165 #define FRAME_BUFFER_STRIDE_STR (((VIDEO_PIXEL_HW_STR * FRAME_BUFFER_BYTE_PER_PIXEL_STR) + 31u) & ~31u)
dkato 2:6ec5c1c1d41c 166
dkato 2:6ec5c1c1d41c 167 static uint8_t user_frame_buffer_string[FRAME_BUFFER_STRIDE_STR * VIDEO_PIXEL_VW_STR]__attribute((section("NC_BSS"),aligned(32)));
dkato 2:6ec5c1c1d41c 168 static AsciiFont ascii_font(user_frame_buffer_string, VIDEO_PIXEL_HW_STR, VIDEO_PIXEL_VW_STR, FRAME_BUFFER_STRIDE_STR, FRAME_BUFFER_BYTE_PER_PIXEL_STR);
dkato 2:6ec5c1c1d41c 169 static bool string_draw;
1050186 6:ea24d9271ff1 170 static int error_cnt;
dkato 2:6ec5c1c1d41c 171
dkato 2:6ec5c1c1d41c 172 static void decode_string_init(void) {
dkato 2:6ec5c1c1d41c 173 DisplayBase::rect_t rect;
dkato 2:6ec5c1c1d41c 174
dkato 2:6ec5c1c1d41c 175 /* The layer by which the touch panel location is drawn */
dkato 2:6ec5c1c1d41c 176 ascii_font.Erase(0x00000000); /* rrrrGBAR (r:Reserve G:Green B:Blue A:Alpha R:Red */
dkato 2:6ec5c1c1d41c 177 rect.vs = 32;
dkato 2:6ec5c1c1d41c 178 rect.vw = VIDEO_PIXEL_VW_STR;
dkato 2:6ec5c1c1d41c 179 rect.hs = 32;
dkato 2:6ec5c1c1d41c 180 rect.hw = VIDEO_PIXEL_HW_STR;
dkato 2:6ec5c1c1d41c 181 Display.Graphics_Read_Setting(
1050186 6:ea24d9271ff1 182 DisplayBase::GRAPHICS_LAYER_2,
dkato 2:6ec5c1c1d41c 183 (void *)user_frame_buffer_string,
dkato 2:6ec5c1c1d41c 184 FRAME_BUFFER_STRIDE_STR,
dkato 2:6ec5c1c1d41c 185 DisplayBase::GRAPHICS_FORMAT_ARGB4444,
dkato 2:6ec5c1c1d41c 186 DisplayBase::WR_RD_WRSWA_32_16BIT,
dkato 2:6ec5c1c1d41c 187 &rect
dkato 2:6ec5c1c1d41c 188 );
1050186 6:ea24d9271ff1 189 Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_2);
dkato 2:6ec5c1c1d41c 190 string_draw = false;
1050186 6:ea24d9271ff1 191 error_cnt = 0;
dkato 2:6ec5c1c1d41c 192 }
dkato 2:6ec5c1c1d41c 193
dkato 2:6ec5c1c1d41c 194 static void decode_string_disp(char ** decode_str) {
dkato 2:6ec5c1c1d41c 195 if ((decode_str != NULL) && (*decode_str != NULL)) {
dkato 2:6ec5c1c1d41c 196 /* Drow string */
dkato 2:6ec5c1c1d41c 197 ascii_font.Erase(0x00000090); /* rrrrGBAR (r:Reserve G:Green B:Blue A:Alpha R:Red */
dkato 2:6ec5c1c1d41c 198 int rest_size = strlen(*decode_str);
dkato 2:6ec5c1c1d41c 199 int draw_idx = 0;
dkato 2:6ec5c1c1d41c 200 int draw_size;
dkato 2:6ec5c1c1d41c 201 int draw_line = 0;
dkato 2:6ec5c1c1d41c 202
dkato 2:6ec5c1c1d41c 203 while (rest_size > 0) {
dkato 2:6ec5c1c1d41c 204 draw_size = ascii_font.DrawStr(*decode_str + draw_idx, 6, 5 + (18 * draw_line), 0x0000ffff, 2);
dkato 2:6ec5c1c1d41c 205 if (draw_size <= 0) {
dkato 2:6ec5c1c1d41c 206 break;
dkato 2:6ec5c1c1d41c 207 }
dkato 2:6ec5c1c1d41c 208 rest_size -= draw_size;
dkato 2:6ec5c1c1d41c 209 draw_idx += draw_size;
dkato 2:6ec5c1c1d41c 210 draw_line++;
dkato 2:6ec5c1c1d41c 211 }
dkato 2:6ec5c1c1d41c 212 string_draw = true;
1050186 6:ea24d9271ff1 213 error_cnt = 0;
dkato 2:6ec5c1c1d41c 214 } else {
dkato 2:6ec5c1c1d41c 215 if (string_draw != false) {
1050186 6:ea24d9271ff1 216 error_cnt++;
1050186 6:ea24d9271ff1 217 if (error_cnt > 15) {
1050186 6:ea24d9271ff1 218 /* Clear string */
1050186 6:ea24d9271ff1 219 ascii_font.Erase(0x00000000); /* rrrrGBAR (r:Reserve G:Green B:Blue A:Alpha R:Red */
1050186 6:ea24d9271ff1 220 string_draw = false;
1050186 6:ea24d9271ff1 221 }
dkato 2:6ec5c1c1d41c 222 }
dkato 2:6ec5c1c1d41c 223 }
dkato 2:6ec5c1c1d41c 224 }
<> 0:eb73febb2bba 225 #endif
<> 0:eb73febb2bba 226
<> 0:eb73febb2bba 227
<> 0:eb73febb2bba 228 /****** zxing_init ******/
<> 0:eb73febb2bba 229 void zxing_init(void (*pfunc)(char * addr, int size)) {
1050186 6:ea24d9271ff1 230 // Initialize the background to black
1050186 6:ea24d9271ff1 231 for (int i = 0; i < (int)sizeof(user_frame_buffer0); i += 2) {
1050186 6:ea24d9271ff1 232 user_frame_buffer0[i + 0] = 0x10;
1050186 6:ea24d9271ff1 233 user_frame_buffer0[i + 1] = 0x80;
1050186 6:ea24d9271ff1 234 }
<> 0:eb73febb2bba 235
1050186 6:ea24d9271ff1 236 #if MBED_CONF_APP_LCD
1050186 6:ea24d9271ff1 237 EasyAttach_Init(Display, 640, 360);
1050186 6:ea24d9271ff1 238 #else
1050186 6:ea24d9271ff1 239 EasyAttach_Init(Display);
1050186 6:ea24d9271ff1 240 #endif
1050186 6:ea24d9271ff1 241 #if JPEG_SEND
1050186 6:ea24d9271ff1 242 Jcu.SetQuality(JPEG_ENCODE_QUALITY);
1050186 6:ea24d9271ff1 243 // Interrupt callback function setting (Field end signal for recording function in scaler 0)
1050186 6:ea24d9271ff1 244 Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_VFIELD, 0, IntCallbackFunc_Vfield);
1050186 6:ea24d9271ff1 245 #endif
1050186 6:ea24d9271ff1 246 Start_Video_Camera();
1050186 6:ea24d9271ff1 247 #if MBED_CONF_APP_LCD
1050186 6:ea24d9271ff1 248 decode_string_init();
1050186 6:ea24d9271ff1 249 Start_LCD_Display();
1050186 6:ea24d9271ff1 250 #endif
<> 0:eb73febb2bba 251
<> 0:eb73febb2bba 252 p_callback_func = pfunc;
<> 0:eb73febb2bba 253 decode_timer.reset();
<> 0:eb73febb2bba 254 decode_timer.start();
<> 0:eb73febb2bba 255 }
<> 0:eb73febb2bba 256
<> 0:eb73febb2bba 257 /****** zxing_main ******/
<> 0:eb73febb2bba 258 int zxing_loop() {
<> 0:eb73febb2bba 259 int decode_result = -1;
<> 0:eb73febb2bba 260 vector<Ref<Result> > results;
dkato 2:6ec5c1c1d41c 261 char ** decode_str = NULL;
<> 0:eb73febb2bba 262
<> 0:eb73febb2bba 263 /* Decode barcode image */
<> 0:eb73febb2bba 264 if (decode_timer.read_ms() >= decode_wait_time) {
<> 0:eb73febb2bba 265 decode_timer.reset();
dkato 2:6ec5c1c1d41c 266 DecodeHints hints(DECODE_HINTS);
dkato 2:6ec5c1c1d41c 267 hints.setTryHarder(false);
dkato 2:6ec5c1c1d41c 268 decode_result = ex_decode(user_frame_buffer0, (FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW), VIDEO_PIXEL_HW, VIDEO_PIXEL_VW, &results, hints);
<> 0:eb73febb2bba 269 if (decode_result == 0) {
<> 0:eb73febb2bba 270 decode_str = (char **)&(results[0]->getText()->getText());
dkato 2:6ec5c1c1d41c 271 int size = strlen(*decode_str);
<> 0:eb73febb2bba 272 if (p_callback_func != NULL) {
<> 0:eb73febb2bba 273 p_callback_func(*decode_str, size);
<> 0:eb73febb2bba 274 }
<> 0:eb73febb2bba 275 decode_wait_time = 500;
<> 0:eb73febb2bba 276 } else {
<> 0:eb73febb2bba 277 decode_wait_time = 10;
<> 0:eb73febb2bba 278 }
1050186 6:ea24d9271ff1 279 #if MBED_CONF_APP_LCD
dkato 2:6ec5c1c1d41c 280 decode_string_disp(decode_str);
1050186 6:ea24d9271ff1 281 #endif
<> 0:eb73febb2bba 282 }
<> 0:eb73febb2bba 283
<> 0:eb73febb2bba 284 return decode_result;
<> 0:eb73febb2bba 285 }
dkato 2:6ec5c1c1d41c 286