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