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