MARMEX_VB test application program. This application works on "mbed NXP LPC1768" only. This application expects to have the MARMEX_VB module on a "MAPLE mini type-B (MARM03-BASE)" baseboard (slot2) with MARMEX_OB module (on slot1)

Dependencies:   MARMEX_VB NokiaLCD mbed

This is the library test program.
The program can test features of the library (refer to MARMEX-VB's API document) and can save captured data into BMP file.

Warning!

This test program can run on "mbed NXP LPC1768" only.

/media/uploads/nxpfan/dsc_0506_-1-.jpg
Picture : sample of test program operation
The modules of MARMEX-VB and MARMEX-OB are set on the "MAPLE mini type-B (MARM03-BASE)" baseboard.
The image data from camera is mirrored and alpha graphics added by software.

Committer:
nxpfan
Date:
Wed Jun 18 06:44:44 2014 +0000
Revision:
6:b61b876d50a8
Parent:
1:dbe2dc31542d
Child:
7:125538c50c22
baseboard type selector added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nxpfan 0:343c01965543 1 /** Test program for MARMEX_VB Camera control library
nxpfan 0:343c01965543 2 *
nxpfan 1:dbe2dc31542d 3 * @version 0.2
nxpfan 0:343c01965543 4 * @date 10-Jun-2014
nxpfan 0:343c01965543 5 *
nxpfan 0:343c01965543 6 * Released under the Apache License, Version 2.0 : http://mbed.org/handbook/Apache-Licence
nxpfan 0:343c01965543 7 *
nxpfan 0:343c01965543 8 * Test program for MARMEX_VB Camera control library
nxpfan 0:343c01965543 9 *
nxpfan 0:343c01965543 10 * ** This program runs on mbed_NXP_LPC1768 only **
nxpfan 0:343c01965543 11 */
nxpfan 0:343c01965543 12
nxpfan 0:343c01965543 13
nxpfan 0:343c01965543 14 #include "mbed.h"
nxpfan 0:343c01965543 15 #include "MARMEX_OB_oled.h"
nxpfan 0:343c01965543 16 #include "MARMEX_VB.h"
nxpfan 0:343c01965543 17 #include "bmp_handler.h"
nxpfan 0:343c01965543 18
nxpfan 6:b61b876d50a8 19 // Baseboard type selection
nxpfan 6:b61b876d50a8 20 #define BASEBOARD_MAPLE_MINI_TYPE_B
nxpfan 6:b61b876d50a8 21 //#define BASEBOARD_MAPLE_ORIGINAL
nxpfan 6:b61b876d50a8 22
nxpfan 6:b61b876d50a8 23 #ifdef BASEBOARD_MAPLE_MINI_TYPE_B
nxpfan 0:343c01965543 24 MARMEX_OB_oled oled1( p5, p7, p20, p16, p15 );
nxpfan 0:343c01965543 25 // mosi, sclk, cs, rst, power_control -- maple-mini-type-b-board-slot1
nxpfan 0:343c01965543 26 MARMEX_VB camera( p5, p6, p7, p22, p26, p28, p27 );
nxpfan 0:343c01965543 27 // mosi, miso, sclk, cs, reset, sda, scl -- maple-mini-type-b-board-slot2
nxpfan 6:b61b876d50a8 28 #endif
nxpfan 6:b61b876d50a8 29
nxpfan 6:b61b876d50a8 30 #ifdef BASEBOARD_MAPLE_ORIGINAL
nxpfan 6:b61b876d50a8 31 MARMEX_OB_oled oled1( p5, p7, p8, p30, p11 );
nxpfan 6:b61b876d50a8 32 // mosi, sclk, cs, rst, power_control -- maple-board-slot1
nxpfan 6:b61b876d50a8 33 MARMEX_VB camera( p5, p6, p7, p26, p17, p28, p27 );
nxpfan 6:b61b876d50a8 34 // mosi, miso, sclk, cs, reset, sda, scl -- maple-board-slot2
nxpfan 6:b61b876d50a8 35 #endif
nxpfan 0:343c01965543 36
nxpfan 0:343c01965543 37 BusOut led( LED4, LED3, LED2, LED1 );
nxpfan 0:343c01965543 38 Timer timer;
nxpfan 0:343c01965543 39
nxpfan 0:343c01965543 40 void test_camera( void );
nxpfan 0:343c01965543 41 void test_camera_resolution_change( void );
nxpfan 0:343c01965543 42
nxpfan 0:343c01965543 43 void copy_image_from_camera_to_oled( void );
nxpfan 1:dbe2dc31542d 44 void copy_image_from_camera_to_oled_small( void );
nxpfan 0:343c01965543 45 void copy_image_from_camera_to_oled_interlaced( void );
nxpfan 0:343c01965543 46 void line_mirroring( short *buf );
nxpfan 0:343c01965543 47 void save_still_image( char *file_name );
nxpfan 0:343c01965543 48 void oled_test_screen( void );
nxpfan 0:343c01965543 49 void capture_to_bmp( void );
nxpfan 0:343c01965543 50
nxpfan 0:343c01965543 51 //#define SAVE_EACH_SIZES_OF_STILL_IMAGE
nxpfan 0:343c01965543 52
nxpfan 0:343c01965543 53 alpha_param ap;
nxpfan 0:343c01965543 54
nxpfan 0:343c01965543 55
nxpfan 0:343c01965543 56 int main()
nxpfan 0:343c01965543 57 {
nxpfan 0:343c01965543 58 printf( "\r\n\r\nMARY-CAMERA test program\r\n\r\n" );
nxpfan 0:343c01965543 59
nxpfan 0:343c01965543 60 read_alpha_BMP( "alpha.bmp", &ap );
nxpfan 0:343c01965543 61
nxpfan 0:343c01965543 62
nxpfan 0:343c01965543 63 led = 0x3;
nxpfan 0:343c01965543 64
nxpfan 0:343c01965543 65 oled1.cls();
nxpfan 0:343c01965543 66 oled_test_screen();
nxpfan 0:343c01965543 67
nxpfan 0:343c01965543 68 #ifdef SAVE_EACH_SIZES_OF_STILL_IMAGE
nxpfan 0:343c01965543 69 led = 0x1;
nxpfan 0:343c01965543 70 camera.resolution( MARMEX_VB::QCIF );
nxpfan 0:343c01965543 71 save_still_image( "i_qcif.bmp" );
nxpfan 0:343c01965543 72
nxpfan 0:343c01965543 73 led = 0x2;
nxpfan 0:343c01965543 74 camera.resolution( MARMEX_VB::QQVGA );
nxpfan 0:343c01965543 75 save_still_image( "i_qqvga.bmp" );
nxpfan 0:343c01965543 76
nxpfan 0:343c01965543 77 led = 0x4;
nxpfan 0:343c01965543 78 camera.resolution( MARMEX_VB::QVGA );
nxpfan 0:343c01965543 79 save_still_image( "i_qvga.bmp" );
nxpfan 0:343c01965543 80
nxpfan 0:343c01965543 81 led = 0x8;
nxpfan 0:343c01965543 82 camera.resolution( MARMEX_VB::VGA );
nxpfan 0:343c01965543 83 save_still_image( "i_vga.bmp" );
nxpfan 0:343c01965543 84
nxpfan 0:343c01965543 85 camera.resolution( MARMEX_VB::QCIF );
nxpfan 0:343c01965543 86 #endif
nxpfan 0:343c01965543 87
nxpfan 0:343c01965543 88 printf( " camera operation started\r\n" );
nxpfan 0:343c01965543 89 printf( " hit key [c] for saving data into BMP (for blue-mbed only)\r\n" );
nxpfan 0:343c01965543 90 printf( " hit key [o] to change data reading order\r\n" );
nxpfan 0:343c01965543 91 printf( " hit key [i] to toggle interlace mode\r\n" );
nxpfan 0:343c01965543 92 printf( " hit key [1], [2], [3] or [4] to change resolution QCIF, QQVGA, QVGA, VGA\r\n" );
nxpfan 0:343c01965543 93
nxpfan 0:343c01965543 94 timer.start(); // timer for measureing frame rate
nxpfan 0:343c01965543 95 test_camera(); // this function doesn't return
nxpfan 0:343c01965543 96 }
nxpfan 0:343c01965543 97
nxpfan 0:343c01965543 98 #if defined( TARGET_MBED_LPC1768 ) || defined( TARGET_LPC11U24_401 )
nxpfan 0:343c01965543 99 Serial pc(USBTX, USBRX); // tx, rx
nxpfan 0:343c01965543 100 #endif
nxpfan 0:343c01965543 101
nxpfan 0:343c01965543 102
nxpfan 0:343c01965543 103 void test_camera( void )
nxpfan 0:343c01965543 104 {
nxpfan 0:343c01965543 105 int interlace = 0;
nxpfan 0:343c01965543 106 int frame_count = 0;
nxpfan 0:343c01965543 107
nxpfan 0:343c01965543 108 while ( 1 ) {
nxpfan 0:343c01965543 109 if ( pc.readable() ) {
nxpfan 0:343c01965543 110 switch ( pc.getc() ) {
nxpfan 0:343c01965543 111 case 'c' :
nxpfan 0:343c01965543 112 capture_to_bmp();
nxpfan 0:343c01965543 113 printf( " [c] : capture started\r\n" );
nxpfan 0:343c01965543 114 break;
nxpfan 0:343c01965543 115 case 'o' :
nxpfan 0:343c01965543 116 printf( " [o] read order change : %s\r\n", camera.read_order_change() ? "ENABLED" : "DISABLED" );
nxpfan 0:343c01965543 117 break;
nxpfan 0:343c01965543 118 case 'i' :
nxpfan 0:343c01965543 119 interlace = !interlace;
nxpfan 0:343c01965543 120 printf( " [i] : interlace setting : %s\r\n", interlace ? "ENABLED" : "DISABLED" );
nxpfan 0:343c01965543 121 /* FALL THROUGH */
nxpfan 0:343c01965543 122 case 'f' :
nxpfan 0:343c01965543 123 if ( frame_count ) {
nxpfan 0:343c01965543 124 timer.stop();
nxpfan 0:343c01965543 125 float t = timer.read();
nxpfan 0:343c01965543 126 printf( " [f] : %s rate : %5.3f\r\n", interlace ? "field" : "frame", (float)frame_count / t );
nxpfan 0:343c01965543 127 frame_count = 0;
nxpfan 0:343c01965543 128 timer.reset();
nxpfan 0:343c01965543 129 timer.start();
nxpfan 0:343c01965543 130 } else {
nxpfan 0:343c01965543 131 printf( " [f] : no frame drawn yet. try again later\r\n" );
nxpfan 0:343c01965543 132 }
nxpfan 0:343c01965543 133 break;
nxpfan 0:343c01965543 134 case '1' :
nxpfan 0:343c01965543 135 printf( " [1] resolution change : QCIF\r\n" );
nxpfan 0:343c01965543 136 camera.init( MARMEX_VB::QCIF );
nxpfan 0:343c01965543 137 break;
nxpfan 0:343c01965543 138 case '2' :
nxpfan 0:343c01965543 139 printf( " [2] resolution change : QQVGA\r\n" );
nxpfan 0:343c01965543 140 camera.init( MARMEX_VB::QQVGA );
nxpfan 0:343c01965543 141 break;
nxpfan 0:343c01965543 142 case '3' :
nxpfan 0:343c01965543 143 printf( " [3] resolution change : QVGA\r\n" );
nxpfan 0:343c01965543 144 camera.init( MARMEX_VB::QVGA );
nxpfan 0:343c01965543 145 break;
nxpfan 0:343c01965543 146 case '4' :
nxpfan 0:343c01965543 147 printf( " [4] resolution change : VGA\r\n" );
nxpfan 0:343c01965543 148 camera.init( MARMEX_VB::VGA );
nxpfan 0:343c01965543 149 break;
nxpfan 0:343c01965543 150 }
nxpfan 0:343c01965543 151 }
nxpfan 0:343c01965543 152
nxpfan 0:343c01965543 153 led = 0x1;
nxpfan 0:343c01965543 154
nxpfan 0:343c01965543 155 if ( interlace )
nxpfan 0:343c01965543 156 copy_image_from_camera_to_oled_interlaced();
nxpfan 0:343c01965543 157 else
nxpfan 0:343c01965543 158 copy_image_from_camera_to_oled();
nxpfan 0:343c01965543 159
nxpfan 0:343c01965543 160 // camera.colorbar( ((count++ >> 2) & 0x1) ? MARMEX_VB::ON : MARMEX_VB::OFF );
nxpfan 0:343c01965543 161
nxpfan 0:343c01965543 162 led = 0x2;
nxpfan 0:343c01965543 163
nxpfan 0:343c01965543 164 frame_count++;
nxpfan 0:343c01965543 165 }
nxpfan 0:343c01965543 166 }
nxpfan 0:343c01965543 167
nxpfan 0:343c01965543 168
nxpfan 0:343c01965543 169 void test_camera_resolution_change( void )
nxpfan 0:343c01965543 170 {
nxpfan 0:343c01965543 171 int count = (3 << 3);
nxpfan 0:343c01965543 172 int setting;
nxpfan 0:343c01965543 173
nxpfan 0:343c01965543 174 while ( 1 ) {
nxpfan 0:343c01965543 175
nxpfan 0:343c01965543 176 if ( !(count & 0x7) ) {
nxpfan 0:343c01965543 177 setting = (count >> 3) & 0x3;
nxpfan 0:343c01965543 178 camera.init( (MARMEX_VB::CameraResolution)(setting + 1) );
nxpfan 0:343c01965543 179 led = 0x1 << setting;
nxpfan 0:343c01965543 180 }
nxpfan 0:343c01965543 181
nxpfan 0:343c01965543 182 count++;
nxpfan 0:343c01965543 183
nxpfan 0:343c01965543 184 copy_image_from_camera_to_oled();
nxpfan 0:343c01965543 185 }
nxpfan 0:343c01965543 186 }
nxpfan 0:343c01965543 187
nxpfan 0:343c01965543 188
nxpfan 0:343c01965543 189 void alpha( int line_num, short *bf, int offset_x, int offset_y, alpha_param *app )
nxpfan 0:343c01965543 190 {
nxpfan 0:343c01965543 191 short r, g, b;
nxpfan 0:343c01965543 192 int y_pos;
nxpfan 0:343c01965543 193
nxpfan 0:343c01965543 194 if ( (line_num < offset_y) || (offset_y + app->v) <= line_num || (app->buffer == NULL) )
nxpfan 0:343c01965543 195 return;
nxpfan 0:343c01965543 196
nxpfan 0:343c01965543 197 bf += offset_x;
nxpfan 0:343c01965543 198 y_pos = ((app->v - (line_num - offset_y + 1)) * (app->h * app->byte_per_pixel));
nxpfan 0:343c01965543 199
nxpfan 0:343c01965543 200 for ( int i = 0; i < 60; i++ ) {
nxpfan 0:343c01965543 201 r = ((*bf >> 1) & 0x0F) + (*(app->buffer + i * 3 + 0 + y_pos ) >> 4);
nxpfan 0:343c01965543 202 g = ((*bf >> 6) & 0x1F) + (*(app->buffer + i * 3 + 1 + y_pos ) >> 3);
nxpfan 0:343c01965543 203 b = ((*bf >> 12) & 0x0F) + (*(app->buffer + i * 3 + 2 + y_pos ) >> 4);
nxpfan 0:343c01965543 204
nxpfan 0:343c01965543 205 *bf++ = (b << 11) | (g << 5) | (r << 0);
nxpfan 0:343c01965543 206 }
nxpfan 0:343c01965543 207 }
nxpfan 0:343c01965543 208
nxpfan 0:343c01965543 209
nxpfan 0:343c01965543 210 void copy_image_from_camera_to_oled( void )
nxpfan 0:343c01965543 211 {
nxpfan 1:dbe2dc31542d 212 short buf[ MARMEX_OB_oled::WIDTH ]; // array size should be multiple of 8 for "mbed LPC1768" optimization
nxpfan 0:343c01965543 213 static int count = 0;
nxpfan 0:343c01965543 214
nxpfan 0:343c01965543 215 camera.open_transfer();
nxpfan 0:343c01965543 216
nxpfan 0:343c01965543 217 for ( int line = 0; line < MARMEX_OB_oled::HEIGHT; line++ ) {
nxpfan 0:343c01965543 218 camera.read_a_line( buf, line + (camera.get_vertical_size() - (int)MARMEX_OB_oled::HEIGHT) / 2, (camera.get_horizontal_size() - (int)MARMEX_OB_oled::WIDTH ) / 2, MARMEX_OB_oled::WIDTH );
nxpfan 0:343c01965543 219 line_mirroring( buf );
nxpfan 0:343c01965543 220 alpha( line, buf, ((count >> 4) & 1) ? 60 : 8, ((count >> 4) & 1) ^ ((count >> 3) & 1) ? ((int)MARMEX_OB_oled::HEIGHT - (ap.v + 4)) : 4, &ap );
nxpfan 0:343c01965543 221 oled1.blit565( 0, line, MARMEX_OB_oled::WIDTH, 1, buf );
nxpfan 0:343c01965543 222 }
nxpfan 0:343c01965543 223
nxpfan 0:343c01965543 224 count++;
nxpfan 0:343c01965543 225 camera.close_transfer();
nxpfan 0:343c01965543 226 }
nxpfan 0:343c01965543 227
nxpfan 0:343c01965543 228
nxpfan 1:dbe2dc31542d 229 void copy_image_from_camera_to_oled_small( void )
nxpfan 1:dbe2dc31542d 230 {
nxpfan 1:dbe2dc31542d 231 short buf[ 64 ];
nxpfan 1:dbe2dc31542d 232 static int count = 0;
nxpfan 1:dbe2dc31542d 233
nxpfan 1:dbe2dc31542d 234 camera.open_transfer();
nxpfan 1:dbe2dc31542d 235
nxpfan 1:dbe2dc31542d 236 for ( int line = 0; line < 64; line++ ) {
nxpfan 1:dbe2dc31542d 237 camera.read_a_line( buf, line, 0, 64 );
nxpfan 1:dbe2dc31542d 238 oled1.blit565( 0, line, 64, 1, buf );
nxpfan 1:dbe2dc31542d 239 }
nxpfan 1:dbe2dc31542d 240
nxpfan 1:dbe2dc31542d 241 count++;
nxpfan 1:dbe2dc31542d 242 camera.close_transfer();
nxpfan 1:dbe2dc31542d 243 }
nxpfan 1:dbe2dc31542d 244
nxpfan 1:dbe2dc31542d 245
nxpfan 0:343c01965543 246 void copy_image_from_camera_to_oled_interlaced( void )
nxpfan 0:343c01965543 247 {
nxpfan 0:343c01965543 248 short buf[ MARMEX_OB_oled::WIDTH ];
nxpfan 0:343c01965543 249 static int count = 0;
nxpfan 0:343c01965543 250
nxpfan 0:343c01965543 251 camera.open_transfer();
nxpfan 0:343c01965543 252
nxpfan 0:343c01965543 253 for ( int line = (count++) & 1; line < MARMEX_OB_oled::HEIGHT; line += 2 ) {
nxpfan 0:343c01965543 254 camera.read_a_line( buf, line + (camera.get_vertical_size() - (int)MARMEX_OB_oled::HEIGHT) / 2, (camera.get_horizontal_size() - (int)MARMEX_OB_oled::WIDTH ) / 2, MARMEX_OB_oled::WIDTH );
nxpfan 0:343c01965543 255 line_mirroring( buf );
nxpfan 0:343c01965543 256 alpha( line, buf, ((count >> 4) & 1) ? 60 : 8, ((count >> 4) & 1) ^ ((count >> 3) & 1) ? ((int)MARMEX_OB_oled::HEIGHT - (ap.v + 4)) : 4, &ap );
nxpfan 0:343c01965543 257 oled1.blit565( 0, line, MARMEX_OB_oled::WIDTH, 1, buf );
nxpfan 0:343c01965543 258 }
nxpfan 0:343c01965543 259
nxpfan 0:343c01965543 260 camera.close_transfer();
nxpfan 0:343c01965543 261 }
nxpfan 0:343c01965543 262
nxpfan 0:343c01965543 263
nxpfan 0:343c01965543 264
nxpfan 0:343c01965543 265 void line_mirroring( short *buf )
nxpfan 0:343c01965543 266 {
nxpfan 0:343c01965543 267 short tmp;
nxpfan 0:343c01965543 268
nxpfan 0:343c01965543 269 for ( int i = 0; i < (MARMEX_OB_oled::WIDTH / 2); i++ ) {
nxpfan 0:343c01965543 270 tmp = buf[ i ];
nxpfan 0:343c01965543 271 buf[ i ] = buf[ (MARMEX_OB_oled::WIDTH - 1) - i ];
nxpfan 0:343c01965543 272 buf[ (MARMEX_OB_oled::WIDTH - 1) - i ] = tmp;
nxpfan 0:343c01965543 273 }
nxpfan 0:343c01965543 274 }
nxpfan 0:343c01965543 275
nxpfan 0:343c01965543 276
nxpfan 0:343c01965543 277 void oled_test_screen( void )
nxpfan 0:343c01965543 278 {
nxpfan 0:343c01965543 279 oled1.background( 0x000000 );
nxpfan 0:343c01965543 280 oled1.cls();
nxpfan 0:343c01965543 281
nxpfan 0:343c01965543 282 int colorbar_width = MARMEX_OB_oled::WIDTH / 8;
nxpfan 0:343c01965543 283
nxpfan 0:343c01965543 284 for ( int i = 0; i < 8; i++ )
nxpfan 0:343c01965543 285 oled1.fill( colorbar_width * i, 0, colorbar_width, MARMEX_OB_oled::HEIGHT, ((i & 0x4) ? 0xFF0000 : 0x000000) | ((i & 0x2) ? 0x00FF00 : 0x000000) | ((i & 0x1) ? 0x0000FF : 0x000000) );
nxpfan 0:343c01965543 286
nxpfan 0:343c01965543 287 oled1.fill( 50, 50, 64, 64, 0xCCCCCC );;
nxpfan 0:343c01965543 288
nxpfan 0:343c01965543 289 oled1.locate( 0, 2 );
nxpfan 0:343c01965543 290 oled1.printf( "MaryCemara test" );
nxpfan 0:343c01965543 291 oled1.locate( 0, 3 );
nxpfan 0:343c01965543 292 oled1.printf( "%s", (MARMEX_VB::NO_ERROR == camera.ready()) ? "Camera is ready" : "No Camera found" );
nxpfan 0:343c01965543 293 oled1.locate( 0, 4 );
nxpfan 1:dbe2dc31542d 294 //oled1.printf( "%s", "saving into BMP" );
nxpfan 0:343c01965543 295 oled1.locate( 0, 5 );
nxpfan 0:343c01965543 296 oled1.printf( "%d", camera.get_horizontal_size() );
nxpfan 0:343c01965543 297 oled1.locate( 0, 6 );
nxpfan 0:343c01965543 298 oled1.printf( "%d", camera.get_vertical_size() );
nxpfan 0:343c01965543 299
nxpfan 0:343c01965543 300
nxpfan 0:343c01965543 301 for (int i = 0; i < MARMEX_OB_oled::WIDTH; i++ )
nxpfan 0:343c01965543 302 oled1.pixel( i, 80 + sin( (float)i / 5.0 ) * 10, 0x000000 );
nxpfan 0:343c01965543 303 }
nxpfan 0:343c01965543 304
nxpfan 0:343c01965543 305
nxpfan 0:343c01965543 306 #include "bmp_handler.h"
nxpfan 0:343c01965543 307
nxpfan 0:343c01965543 308 void save_still_image( char *file_name )
nxpfan 0:343c01965543 309 {
nxpfan 0:343c01965543 310 short buf[ camera.get_horizontal_size() ];
nxpfan 0:343c01965543 311
nxpfan 0:343c01965543 312 if ( open_BMP( file_name, camera.get_horizontal_size(), camera.get_vertical_size() ) )
nxpfan 0:343c01965543 313 return;
nxpfan 0:343c01965543 314
nxpfan 0:343c01965543 315 camera.open_transfer();
nxpfan 0:343c01965543 316
nxpfan 0:343c01965543 317 for ( int line = (camera.get_vertical_size() - 1); 0 <= line; line-- ) {
nxpfan 0:343c01965543 318 camera.read_a_line( buf, line, 0, camera.get_horizontal_size() );
nxpfan 0:343c01965543 319 write_BMP( buf, camera.get_horizontal_size() );
nxpfan 0:343c01965543 320 }
nxpfan 0:343c01965543 321 camera.close_transfer();
nxpfan 0:343c01965543 322
nxpfan 0:343c01965543 323 close_BMP();
nxpfan 0:343c01965543 324 }
nxpfan 0:343c01965543 325
nxpfan 0:343c01965543 326 void capture_to_bmp( void )
nxpfan 0:343c01965543 327 {
nxpfan 0:343c01965543 328 short buf[ camera.get_horizontal_size() ];
nxpfan 0:343c01965543 329 camera.open_transfer();
nxpfan 0:343c01965543 330
nxpfan 0:343c01965543 331 if ( open_BMP( "RGB.bmp", camera.get_horizontal_size(), camera.get_vertical_size() ) )
nxpfan 0:343c01965543 332 return;
nxpfan 0:343c01965543 333
nxpfan 0:343c01965543 334 for ( int line = (camera.get_vertical_size() - 1); 0 <= line; line-- ) {
nxpfan 0:343c01965543 335 camera.read_a_line( buf, line, 0, camera.get_horizontal_size() );
nxpfan 0:343c01965543 336 // write_BMP( buf, camera.get_horizontal_size(), 0x7 );
nxpfan 0:343c01965543 337 write_BMP( buf, camera.get_horizontal_size() );
nxpfan 0:343c01965543 338 }
nxpfan 0:343c01965543 339
nxpfan 0:343c01965543 340 close_BMP();
nxpfan 0:343c01965543 341
nxpfan 0:343c01965543 342 #if 0
nxpfan 0:343c01965543 343
nxpfan 0:343c01965543 344 if ( open_BMP( "R.bmp", camera.get_horizontal_size(), camera.get_vertical_size() ) )
nxpfan 0:343c01965543 345 return;
nxpfan 0:343c01965543 346
nxpfan 0:343c01965543 347 for ( int line = (camera.get_vertical_size() - 1); 0 <= line; line-- ) {
nxpfan 0:343c01965543 348 camera.read_a_line( buf, line, 0, camera.get_horizontal_size() );
nxpfan 0:343c01965543 349 write_BMP( buf, camera.get_horizontal_size(), 0x4 );
nxpfan 0:343c01965543 350 }
nxpfan 0:343c01965543 351
nxpfan 0:343c01965543 352 close_BMP();
nxpfan 0:343c01965543 353
nxpfan 0:343c01965543 354
nxpfan 0:343c01965543 355 if ( open_BMP( "G.bmp", camera.get_horizontal_size(), camera.get_vertical_size() ) )
nxpfan 0:343c01965543 356 return;
nxpfan 0:343c01965543 357
nxpfan 0:343c01965543 358 for ( int line = (camera.get_vertical_size() - 1); 0 <= line; line-- ) {
nxpfan 0:343c01965543 359 camera.read_a_line( buf, line, 0, camera.get_horizontal_size() );
nxpfan 0:343c01965543 360 write_BMP( buf, camera.get_horizontal_size(), 0x2 );
nxpfan 0:343c01965543 361 }
nxpfan 0:343c01965543 362
nxpfan 0:343c01965543 363 close_BMP();
nxpfan 0:343c01965543 364
nxpfan 0:343c01965543 365
nxpfan 0:343c01965543 366 if ( open_BMP( "B.bmp", camera.get_horizontal_size(), camera.get_vertical_size() ) )
nxpfan 0:343c01965543 367 return;
nxpfan 0:343c01965543 368
nxpfan 0:343c01965543 369 for ( int line = (camera.get_vertical_size() - 1); 0 <= line; line-- ) {
nxpfan 0:343c01965543 370 camera.read_a_line( buf, line, 0, camera.get_horizontal_size() );
nxpfan 0:343c01965543 371 write_BMP( buf, camera.get_horizontal_size(), 0x1 );
nxpfan 0:343c01965543 372 }
nxpfan 0:343c01965543 373
nxpfan 0:343c01965543 374 close_BMP();
nxpfan 0:343c01965543 375
nxpfan 0:343c01965543 376 #endif
nxpfan 0:343c01965543 377 camera.close_transfer();
nxpfan 0:343c01965543 378 }