apps/png/pnghist.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <fcntl.h>
#include <math.h>
#include <asm/elphel/autoexp.h>
#include <asm/elphel/hist.h>
#include <sys/mman.h>
#include <asm/elphel/c313a.h>
#include "libpng/png.h"

Include dependency graph for pnghist.c:

Go to the source code of this file.

Data Structures

struct  key_value

Defines

#define HIST_SIZE   256 * 4 * 4
#define HPNG_PLOT_BARS   1
#define HPNG_CONNECT_DOTS   2
#define HPNG_FILL_ZEROS   4
#define HPNG_LIN_INTERP   8
#define HPNG_RUN_SQRT   16
#define QRY_MAXPARAMS   64
#define HPNG_PLOT_BARS   1
#define ERROR   -1
#define OK   0

Functions

int unescape (char *, int)
int hexdigit (char)
char * paramValue (struct key_value *, char *)
int parseQuery (struct key_value *, char *)
int write_png (int height, int data[1024], int mode, int colors)
int main (int argc, char *argv[])
int write_png (int png_height, int data[1536], int mode, int colors)

Variables

char copyQuery [4096]
const char * uri
const char * method
const char * query
key_value gparams [QRY_MAXPARAMS+1]
autoexp_t autoexp


Define Documentation

#define ERROR   -1

Definition at line 258 of file pnghist.c.

Referenced by parseGetNames(), and write_png().

#define HIST_SIZE   256 * 4 * 4

-----------------------------------------------------------------------------** pnghist.c

Copyright (C) 2006-2008 Elphel, Inc.

-----------------------------------------------------------------------------** This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. -----------------------------------------------------------------------------**

Definition at line 41 of file pnghist.c.

Referenced by main().

#define HPNG_CONNECT_DOTS   2

Definition at line 44 of file pnghist.c.

#define HPNG_FILL_ZEROS   4

Definition at line 45 of file pnghist.c.

Referenced by main().

#define HPNG_LIN_INTERP   8

Definition at line 46 of file pnghist.c.

Referenced by main().

#define HPNG_PLOT_BARS   1

Definition at line 43 of file pnghist.c.

#define HPNG_PLOT_BARS   1

Definition at line 43 of file pnghist.c.

#define HPNG_RUN_SQRT   16

Definition at line 47 of file pnghist.c.

Referenced by main().

#define OK   0

Definition at line 259 of file pnghist.c.

Referenced by write_png().

#define QRY_MAXPARAMS   64

Definition at line 49 of file pnghist.c.


Function Documentation

int hexdigit ( char   ) 

Definition at line 25 of file unescape.c.

int main ( int  argc,
char *  argv[] 
)

*************************************************************************** ! FILE NAME : autoexposure.c ! DESCRIPTION: Daemon to adjust camera exposure and white balance ! Copyright (C) 2008 Elphel, Inc. ! -----------------------------------------------------------------------------** ! This program is free software: you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation, either version 3 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program. If not, see <http://www.gnu.org/licenses/>. ! -----------------------------------------------------------------------------** ! !

Log
autoexposure.c,v
! Revision 1.1.1.1 2008/11/27 20:04:01 elphel ! ! ! Revision 1.16 2008/11/18 19:30:16 elphel ! Added initialization of the "next" frame - otherwise it wait _very_ long if the camera frame number is reset ! ! Revision 1.15 2008/11/15 23:08:24 elphel ! 8.0.alpha17 - split autoexposure source file ! ! Revision 1.14 2008/11/15 07:05:38 elphel ! implemented analog gain control (in addition to gammas) while while balancing ! ! Revision 1.13 2008/11/15 03:10:13 elphel ! Some parameters renamed, reassigned. ! ! Revision 1.12 2008/11/14 07:13:32 elphel ! Added gammaReverse() and gammaDirect() functions, TODO lists, bug fixes ! ! Revision 1.11 2008/11/14 01:01:59 elphel ! cleared debug output ! ! Revision 1.10 2008/11/13 05:40:45 elphel ! 8.0.alpha16 - modified histogram storage, profiling ! ! Revision 1.9 2008/11/08 05:52:21 elphel ! debug feature ! ! Revision 1.8 2008/11/04 17:40:34 elphel ! comment typos ! ! Revision 1.7 2008/11/02 00:32:35 elphel ! added TODO ! ! Revision 1.6 2008/10/31 18:26:32 elphel ! Adding support for constants like SENSOR_REGS32 (defined constant plus 32 to simplify referencing sensor registers from PHP ! ! Revision 1.5 2008/10/29 04:18:28 elphel ! v.8.0.alpha10 made a separate structure for global parameters (not related to particular frames in a frame queue) ! ! Revision 1.4 2008/10/28 07:05:12 elphel ! implemented white balance, HDR mode (1/1 and 2/2) ! ! Revision 1.3 2008/10/26 05:55:38 elphel ! snapshot ! ! Revision 1.2 2008/10/25 19:49:15 elphel ! 8.0.alpha8 - added autoexposure to the installation ! ! Revision 1.1 2008/10/24 00:34:12 elphel ! initial release !

array of histogram

colors 1 - r, 2 - g1, 4 - g2, 8 - b, 16 - w, 32 - g1+g2

enable requesting histogram calculation for the specified frame (0 - use/wait what available)

Sample from camvc.html http://192.168.0.9/pnghist.cgi?sqrt=1&scale=5&average=5&height=128&fillz=1&linterpz=0&draw=2&colors=41 FIXME: Some bump on low red - what is it?

instead of autoexp_fd

now try to mmap

Now find the index of the most recently available histogram (maybe will wait a little if it is not yet available for the current frame - use previous?)

wait for all histograms, not just Y (G1)

forward and cumulative histograms are needed

disable requesting histogram for the specified frame, rely on the available ones

request histograms for the previous frame

Ignore missing histograms here

cumul_hist_g[255] - total number of pixels for color G1

linear interpolation - also for high digital gains (near black with low gammas)

apply running average (if any)

calculate white if needed

calculate green if needed

now scale data

Definition at line 73 of file pnghist.c.

References a, copyQuery, histogram_stuct_t::cumul_hist_g, exit, fd_histogram_cache, gparams, hist, hist_index, HIST_SIZE, histogram_cache, HISTOGRAM_CACHE_NUMBER, HPNG_FILL_ZEROS, HPNG_LIN_INTERP, HPNG_RUN_SQRT, LSEEK_HIST_NEEDED, LSEEK_HIST_REQ_DIS, LSEEK_HIST_REQ_EN, LSEEK_HIST_WAIT_C, memcpy(), method, mode, paramValue(), parseQuery(), query, SEEK_CUR, SEEK_END, stderr, stdout, unescape(), uri, and write_png().

char* paramValue ( struct key_value ,
char *   
)

int parseQuery ( struct key_value ,
char *   
)

int unescape ( char *  ,
int   
)

int write_png ( int  png_height,
int  data[1536],
int  mode,
int  colors 
)

Definition at line 264 of file pnghist.c.

References d, ERROR, height, image, info_ptr, memset(), OK, palette, png_bytep, PNG_COLOR_TYPE_PALETTE, PNG_COMPRESSION_TYPE_BASE, png_create_info_struct(), png_create_write_struct(), png_destroy_write_struct(), png_error(), PNG_FILTER_TYPE_BASE, png_infopp_NULL, png_init_io(), PNG_INTERLACE_NONE, png_jmpbuf, PNG_LIBPNG_VER_STRING, PNG_MAX_PALETTE_LENGTH, png_set_IHDR(), png_set_interlace_handling(), png_set_PLTE(), png_set_sBIT(), png_set_text(), png_set_tRNS(), png_sizeof, PNG_TEXT_COMPRESSION_NONE, PNG_TEXT_COMPRESSION_zTXt, png_uint_32, PNG_UINT_32_MAX, png_write_end(), png_write_image(), png_write_info(), row_pointers, sig_bit, stdout, text_ptr, trans, and width.

int write_png ( int  height,
int  data[1024],
int  mode,
int  colors 
)

Referenced by main().


Variable Documentation

struct autoexp_t autoexp

Definition at line 71 of file pnghist.c.

char copyQuery[4096]

Definition at line 53 of file pnghist.c.

struct key_value gparams[QRY_MAXPARAMS+1]

Definition at line 63 of file pnghist.c.

const char* method

Definition at line 55 of file pnghist.c.

const char* query

Definition at line 56 of file pnghist.c.

const char* uri

Definition at line 54 of file pnghist.c.


Generated on Fri Nov 28 00:07:22 2008 for elphel by  doxygen 1.5.1