Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * qa_jpegbm.h - QA for benchmarking jpeg compression 00004 * 00005 * Created: Fri Jul 20 13:22:51 2007 00006 * Copyright 2005-2007 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 /// @cond QA 00025 00026 #include <fvutils/color/colorspaces.h> 00027 #include <fvutils/compression/jpeg_compressor.h> 00028 00029 #include <utils/time/tracker.h> 00030 #include <iostream> 00031 #include <cstdlib> 00032 00033 using namespace std; 00034 using namespace fawkes; 00035 using namespace firevision; 00036 00037 #define IMAGE_WIDTH 500 00038 #define IMAGE_HEIGHT 500 00039 00040 #define NUM_CYCLES 100 00041 00042 // ~ 500 KB should be enough 00043 #define DEST_BUF_SIZE 500000 00044 00045 int 00046 main(int argc, char **argv) 00047 { 00048 00049 unsigned char *yuv422planar = malloc_buffer(YUV422_PLANAR, IMAGE_WIDTH, IMAGE_HEIGHT); 00050 unsigned char *compressed = (unsigned char *)malloc(DEST_BUF_SIZE); 00051 00052 JpegImageCompressor *jpeg = new JpegImageCompressor(JpegImageCompressor::JPEG_CS_RGB); 00053 jpeg->set_image_dimensions(IMAGE_WIDTH, IMAGE_HEIGHT); 00054 jpeg->set_image_buffer(YUV422_PLANAR, yuv422planar); 00055 jpeg->set_destination_buffer(compressed, DEST_BUF_SIZE); 00056 jpeg->set_compression_destination(ImageCompressor::COMP_DEST_MEM); 00057 00058 TimeTracker *tracker = new TimeTracker(); 00059 00060 for ( unsigned int i = 0; i < NUM_CYCLES; ++i) { 00061 jpeg->compress(); 00062 tracker->ping(0); 00063 } 00064 00065 tracker->print_to_stdout(); 00066 00067 delete tracker; 00068 delete jpeg; 00069 free(compressed); 00070 free(yuv422planar); 00071 00072 return 0; 00073 } 00074 00075 00076 00077 /// @endcond