Ryo Hagimoto / Mbed 2 deprecated GR-PEACH_Camera_in_barcode

Dependencies:   GR-PEACH_video mbed zbar_010

Fork of GR-PEACH_Camera_in by Renesas

Files at this revision

API Documentation at this revision

Comitter:
RyoheiHagimoto
Date:
Tue Apr 19 02:00:57 2016 +0000
Parent:
1:aaa4b3e0f03c
Child:
3:02a36eaa7261
Commit message:
first revision

Changed in this revision

USBHost.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
zbar_010.lib Show annotated file Show diff for this revision Revisions of this file
--- a/USBHost.lib	Mon Apr 18 07:14:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/USBHost/#028508fd50fa
--- 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zbar_010.lib	Tue Apr 19 02:00:57 2016 +0000
@@ -0,0 +1,1 @@
+zbar_010#56c5742b9e2b