GR-PEACH barcode reader. This program uses ZBar bar code reader. ZBar is licensed under the GNU LGPL 2.1 to enable development of both open source and commercial projects.
Dependencies: GR-PEACH_video mbed zbar_010
Fork of GR-PEACH_Camera_in by
How to use
- Push USER_BUTTON0, then output the result to terminal.
License
The ZBar Bar Code Reader is Copyright (C) 2007-2009 Jeff Brown <spadix@users.sourceforge.net> The QR Code reader is Copyright (C) 1999-2009 Timothy B. Terriberry <tterribe@xiph.org>
You can redistribute this library and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
ISAAC is based on the public domain implementation by Robert J. Jenkins Jr., and is itself public domain.
Portions of the bit stream reader are copyright (C) The Xiph.Org Foundation 1994-2008, and are licensed under a BSD-style license.
The Reed-Solomon decoder is derived from an implementation (C) 1991-1995 Henry Minsky (hqm@ua.com, hqm@ai.mit.edu), and is licensed under the LGPL with permission.
know how
please see this page.
Diff: main.cpp
- Revision:
- 2:8fd6cd76716a
- Parent:
- 1:aaa4b3e0f03c
--- a/main.cpp Mon Apr 18 07:14:02 2016 +0000 +++ b/main.cpp Tue Apr 19 02:00:57 2016 +0000 @@ -1,12 +1,21 @@ #include "mbed.h" #include "DisplayBace.h" +#if (1) // USB is not used +#else #include "USBHostMSD.h" +#endif #include "bitmap.h" #if defined(TARGET_RZ_A1H) +#if (1) // USB is not used +#else #include "usb_host_setting.h" +#endif #else #define USB_HOST_CH 0 #endif +#if (1) // Add ZBar +#include "zbar_lib.h" +#endif #define VIDEO_CVBS (0) /* Analog Video Signal */ #define VIDEO_CMOS_CAMERA (1) /* Digital Video Signal */ @@ -15,8 +24,8 @@ #define VIDEO_RGB565 (2) /**** User Selection *********/ -#define VIDEO_INPUT_METHOD (VIDEO_CVBS) /* Select VIDEO_CVBS or VIDEO_CMOS_CAMERA */ -#define VIDEO_INPUT_FORMAT (VIDEO_RGB888) /* Select VIDEO_YCBCR422 or VIDEO_RGB888 or VIDEO_RGB565 */ +#define VIDEO_INPUT_METHOD (VIDEO_CMOS_CAMERA) /* Select VIDEO_CVBS or VIDEO_CMOS_CAMERA */ +#define VIDEO_INPUT_FORMAT (VIDEO_YCBCR422) /* Select VIDEO_YCBCR422 or VIDEO_RGB888 or VIDEO_RGB565 */ #define USE_VIDEO_CH (0) /* Select 0 or 1 If selecting VIDEO_CMOS_CAMERA, should be 0.) */ #define VIDEO_PAL (0) /* Select 0(NTSC) or 1(PAL) If selecting VIDEO_CVBS, this parameter is not referenced.) */ /*****************************/ @@ -60,6 +69,14 @@ static volatile int32_t vsync_count; static volatile int32_t vfield_count; +#if (1) // Add image buffer */ +static unsigned char input_image_buff[320*240]; +#endif + +#if (1) // Add YCbCr422 to Grayscale converter */ +static void yuv2gray(void * dst_buff, void * src_buff, uint32_t stride, uint32_t height ); +#endif + /**************************************************************************//** * @brief Interrupt callback function * @param[in] int_type : VDC5 interrupt type @@ -248,6 +265,8 @@ /* Wait 2 Vfield(Top or bottom field) */ WaitVfield(2); +#if (1) // USB is not used +#else #if (USB_HOST_CH == 1) //Audio Shield USB1 //Audio Shield USB1 enable usb1en = 1; //Outputs high level @@ -258,6 +277,7 @@ char file_name[32]; int file_name_index = 0; int save_file_size; +#endif while (1) { /* button check */ @@ -283,6 +303,8 @@ /* Wait 2 Vfield(Top or bottom field) */ WaitVfield(2); +#if (1) // USB is not used +#else /* FrameBuffer_Video_AorB capture completed */ /* USB connect check */ while (!msd.connected()) { @@ -292,14 +314,20 @@ break; } } +#endif /* Data save */ #if ( VIDEO_INPUT_FORMAT == VIDEO_YCBCR422 || VIDEO_INPUT_FORMAT == VIDEO_RGB565 ) +#if (1) /* converting YCbCr to Grayscale and calling zbar_main */ + yuv2gray(input_image_buff,save_buff_addr,VIDEO_BUFFER_STRIDE,VIDEO_BUFFER_HEIGHT); + zbar_main(input_image_buff,PIXEL_HW,PIXEL_VW); +#else /* Save ".bin" file */ sprintf(file_name, "/usb/video_%d.bin", file_name_index++); FILE * fp = fopen(file_name, "w"); save_file_size = fwrite(save_buff_addr, sizeof(char), (VIDEO_BUFFER_STRIDE * VIDEO_BUFFER_HEIGHT), fp); fclose(fp); +#endif #else /* Save ".bmp" file */ sprintf(file_name, "/usb/video_%d.bmp", file_name_index++); @@ -307,8 +335,46 @@ bitmap bitmapfile; save_file_size = bitmapfile.Rgb888ToBmp(file_name, save_buff_addr, PIXEL_HW, PIXEL_VW); #endif +#if (1) // USB is not used +#else printf("file name %s, file size %d\n", file_name, save_file_size); +#endif led1 = 0; } } } + +#if (1) // Add YCbCr422 to Grayscale converter */ +/**************************************************************************//** + * @brief Convert YCbCr422 to Grayscale + * @param[in] void * dst_buff + void * src_buff + uint32_t stride + uint32_t height + * @retval None +******************************************************************************/ +/* Convert YCbCr422 to Grayscale */ +static void yuv2gray(void * dst_buff, void * src_buff, uint32_t stride, uint32_t height ) +{ + uint32_t count; + uint32_t * src; + uint32_t * dst; + uint32_t data1; + uint32_t data2; + + src = (uint32_t *)src_buff; + dst = (uint32_t *)dst_buff; + + for( count = 0 ; count < stride * height -1 ; ) + { + data1 = *src++; + data2 = *src++; + + *dst++ = ( (data1 & 0x000000ff) << 24 ) + + ( (data1 & 0x00ff0000) << 0 ) + + ( (data2 & 0x000000ff) << 8 ) + + ( (data2 & 0x00ff0000) >> 16 ); + count += 8; + } +} /* End of function yuv2gray() */ +#endif