Utility
[EDT Digital Imaging Library]


Detailed Description

Various utility subroutines.

Most PDV utility routines have a dvu_ prefix. dvu_ subroutines are not necessarily specific to the EDT digital imaging hardware. For example, dvu_write_rasfile could concievably be used to write a raster file from any source, not just one captured by an EDT framegrabber. As such, dvu_ subroutines do not operate on an PdvDev device handle in their parameter lists.

There are a few utility subroutines that don't take a PdvDev device handle but do have a pdv_ prefix, and may or may not have some PDV specificity.

The remaining pdv_ subroutines that do take a PdvDev device handle are tagged as utility subroutines because they do not fit any other category.


Defines

#define BI_BITFIELDS   3L
#define BI_RGB   0L
#define BI_RLE4   2L
#define BI_RLE8   1L
#define BYTE   unsigned char
#define DVUFATAL   PDVLIB_MSG_FATAL
#define DWORD   unsigned int
#define LONG   int
#define RAS_MAGIC   0x59a66a95
#define RMT_EQUAL_RGB   1
#define RMT_NONE   0
#define RT_STANDARD   1
#define WIDTHBYTES(bits)   (((bits) + 31) / 32 * 4)
#define WORD   unsigned short

Functions

int dvu_exp_histeq (u_char *src, u_char *dst, int size, int depth, int cutoff)
 Perform a histogram equalization on an image, with cutoff (experimental).
void dvu_free_tables ()
int dvu_free_window (dvu_window *w)
int dvu_histeq (u_char *src, u_char *dst, int size, int depth)
 Perform a histogram equalization on an image.
dvu_window * dvu_init_window (u_char *data, int sx, int sy, int dx, int dy, int xdim, int ydim, int depth)
int dvu_load_lookup (char *filename, int depth)
void dvu_long_to_charbuf (unsigned int val, u_char *buf)
int dvu_lookup (u_char *src, u_char *dst, int size, int depth)
void dvu_perror (char *str)
dvu_window * dvu_read_window (char *fname)
dvu_window * dvu_reset_window (dvu_window *s, u_char *data, int sx, int sy, int dx, int dy)
int dvu_save_lookup (char *filename, int depth)
int dvu_winscale (dvu_window *wi, dvu_window *bi, int minbyte, int maxbyte, int doinit)
int dvu_word2byte (u_short *wbuf, u_char *bbuf, int count, int depth)
int dvu_word2byte_with_stride (u_short *wbuf, u_char *bbuf, int wstride, int bstride, int xsize, int ysize, int depth)
int dvu_wordscale (u_short *words, u_char *bytes, int count, int minbyte, int maxbyte, int doinit)
int dvu_write_bmp (char *fname, u_char *buffer, int width, int height)
 Writes an 8-bit per pixel data buffer as a grayscale Windows bitmap file.
int dvu_write_bmp_24 (char *fname, u_char *buffer, int width, int height)
 Writes a 24-bit per pixel RGB data buffer as a Windows bitmap file.
int dvu_write_image (char *fname, u_char *addr, int x_size, int y_size, int istride)
 Utility routine that outputs a 1-band, 8-bit image to a Sun raster format file (regardless of platform), with stride.
int dvu_write_image24 (char *fname, u_char *addr, int x_size, int y_size, int istride)
 Writes a 24-bit per pixel RGB data buffer as a Sun Raster format file, with stride.
int dvu_write_rasfile (char *fname, u_char *addr, int x_size, int y_size)
 Utility routine that outputs a 1-band, 8-bit image to a Sun raster format file (regardless of platform).
int dvu_write_rasfile16 (char *fname, u_char *addr, int x_size, int y_size, int depth_bits)
 converts 1 band, 10-16 bit image to a sun raster format file and writes to a file.
int dvu_write_rasfile24 (char *fname, u_char *addr, int x_size, int y_size)
 Writes a 24-bit per pixel RGB data buffer as a Sun Raster format file.
int dvu_write_raw (int imagesize, u_char *imagebuf, char *fname)
 Writes a 24-bit per pixel RGB data buffer as a raw data file (no formatting).
int dvu_write_window (char *fname, dvu_window *w)
int pdv_access (char *fname, int perm)
 Determines file access independent of operating system.
uchar_t * pdv_alloc (int size)
 Convenience routine to allocate memory in a system-independent way.
int pdv_bytes_per_line (int width, int depth)
 Returns bytes per line based on width and bit depth, including depth < 8.
int pdv_cl_camera_connected (PdvDev *pdv_p)
 Checks whether a camera is connected and turned on.
void pdv_free (uchar_t *ptr)
 Convenience routine to free the memory allocated with pdv_alloc.
int pdv_is_atmel (PdvDev *pdv_p)
 Infers that this device is connected to is an Atmel camera, based on the camera_class directive.
int pdv_is_cameralink (PdvDev *pdv_p)
 Infers that this device is connected to is a Camera Link camera (as opposed to RS-422 or LVDS parallel), based on settings from the loaded camera config file.
int pdv_is_dvc (PdvDev *pdv_p)
 Infers that this device is connected to is a DVC camera, from settings from the loaded camera config file.
int pdv_is_hamamatsu (PdvDev *pdv_p)
 Infers that this device is connected to is a Hamamatsu camera based on the camera class string.
int pdv_is_kodak_i (PdvDev *pdv_p)
 Infer if it's a Redlake (formerly Roper, formerly Kodak) 'i' camera from the serial settings.
int pdv_is_simulator (PdvDev *pdv_p)
 Infers that this device is a simulator -- either a PCI DV CLS board, or a PCIe DV C-Link with simulator FPGA loaded.
void pdv_perror (char *err)
 Formats and prints a system error.
int pdv_update_values_from_camera (PdvDev *pdv_p)
 Deprecated -- Queries certain specific cameras via serial, and sets library variables for gain, black level, exposure time and binning to values based on the results of the query.
int ten2one (u_short *wbuf, u_char *bbuf, int count)

Variables

int Pdv_debug


Function Documentation

int dvu_exp_histeq ( u_char *  src,
u_char *  dst,
int  size,
int  depth,
int  cutoff 
)

Perform a histogram equalization on an image, with cutoff (experimental).

Parameters:
src source buffer
dst destination buffer
size size in pixels
depth depth in bits
cutoff histogram cutoff

Definition at line 964 of file libdvu.c.

int dvu_histeq ( u_char *  src,
u_char *  dst,
int  size,
int  depth 
)

Perform a histogram equalization on an image.

Parameters:
src source buffer
dst destination buffer
size size in pixels
depth depth in bits

Definition at line 800 of file libdvu.c.

int dvu_write_bmp ( char *  fname,
u_char *  buffer,
int  width,
int  height 
)

Writes an 8-bit per pixel data buffer as a grayscale Windows bitmap file.

Example

 int err=dvu_write_bmp("file.bmp", buf_p, 
           pdv_get_width(pdv_p),
           pdv_get_height(pdv_p)
         );

Parameters:
fname filename
buffer data buffer, one byte per pixel
width number of pixels (bytes) per line
height number of lines in the image
Returns:
0 on success, -1 on failure.
See also:
dvu_write_bmp_24

Definition at line 1269 of file libdvu.c.

int dvu_write_bmp_24 ( char *  fname,
u_char *  buffer,
int  width,
int  height 
)

Writes a 24-bit per pixel RGB data buffer as a Windows bitmap file.

Example

 int err=dvu_write_bmp("file.bmp", buf_p, pdv_get_width(pdv_p),
 pdv_get_height(pdv_p);

Parameters:
fname filename
buffer data buffer, one byte per pixel
width number of pixels (bytes) per line
height number of lines in the image
Returns:
0 on success, -1 on failure.
See also:
dvu_write_bmp

Definition at line 1417 of file libdvu.c.

int dvu_write_image ( char *  fname,
u_char *  addr,
int  x_size,
int  y_size,
int  istride 
)

Utility routine that outputs a 1-band, 8-bit image to a Sun raster format file (regardless of platform), with stride.

This function can be used to output a partial image. For example, to output the top left 100x100 pixels of the image, specify x_size of 100 and y_size * 100, and an istride of the actual width of the image.

Note:
Use dvu_write_rasfile to output a full image in the most efficient way.
Parameters:
fname the name of the output file
addr the address of the image data (8 bits per pixel)
x_size width in pixels of image
y_size height in pixels of image
istride number of pixels (bytes) to skip from one the beginning of one line to the beginning of the next (this should just be the image width, unless you want something weird like a diagonally skewed image).
Returns:
0 on success, -1 on failure

Definition at line 494 of file libdvu.c.

int dvu_write_image24 ( char *  fname,
u_char *  addr,
int  x_size,
int  y_size,
int  istride 
)

Writes a 24-bit per pixel RGB data buffer as a Sun Raster format file, with stride.

Note:
To output a full image in the most efficient way, use dvu_write_rasfile24.
Parameters:
fname the name of output file
addr data buffer, three bytes per pixel (RGB)
x_size number of pixels per line
y_size number of lines in the image
istride number of pixels to skip between sucessive lines
Example
 // skip every other line
 int err=dvu_write_image24("file.ras", buf_p, 
            pdv_get_width(pdv_p),
            pdv_get_height(pdv_p) / 2, 
            pdv_get_width(pdv_p)
         );

Returns:
0 on success, -1 on failure

Definition at line 619 of file libdvu.c.

int dvu_write_rasfile ( char *  fname,
u_char *  addr,
int  x_size,
int  y_size 
)

Utility routine that outputs a 1-band, 8-bit image to a Sun raster format file (regardless of platform).

Parameters:
fname the name of the output file
addr the address of the image data (8 bits per pixel)
x_size width in pixels of image
y_size height in pixels of image
Returns:
0 on success, -1 on failure

Definition at line 197 of file libdvu.c.

int dvu_write_rasfile16 ( char *  fname,
u_char *  addr,
int  x_size,
int  y_size,
int  depth_bits 
)

converts 1 band, 10-16 bit image to a sun raster format file and writes to a file.

Parameters:
fname the name of the output file
addr the address of the image data (8 bits per pixel)
x_size width in pixels of image
y_size height in pixels of image
depth_bits number of bits per pixel
Returns:
0 on success, -1 on failure

Definition at line 266 of file libdvu.c.

int dvu_write_rasfile24 ( char *  fname,
u_char *  addr,
int  x_size,
int  y_size 
)

Writes a 24-bit per pixel RGB data buffer as a Sun Raster format file.

Parameters:
fname file name
addr data buffer, three bytes per pixel (RGB)
x_size number of pixels per line
y_size number of lines in the image
Returns:
0 on success, -1 on failure

Definition at line 553 of file libdvu.c.

int dvu_write_raw ( int  imagesize,
u_char *  imagebuf,
char *  fname 
)

Writes a 24-bit per pixel RGB data buffer as a raw data file (no formatting).

Example

 int err=dvu_write_raw(pdv_get_imagesize(pdv_p), buf_p, "file.raw");

Parameters:
imagesize number of bytes in the image.
imagebuf pointer to image data buffer.
fname output file name.
Returns:
0 on success, -1 on failure.

Definition at line 1535 of file libdvu.c.

int pdv_access ( char *  fname,
int  perm 
)

Determines file access independent of operating system.

This a convenience routine that maps to access() on Unix/Linux systems, and _access on Windows systems.

Parameters:
fname path name of the file to check access of.
perm permission flag(s) to test for. See access() (Unix/Linux) or _access (Windows) for valid arguments.
Example
 if (pdv_access("file.ras", F_OK))
     print("Warning: about to overwrite file %s/n", "file.ras");

Returns:
0 on success, -1 on failure.

Definition at line 8106 of file libpdv.c.

uchar_t* pdv_alloc ( int  size  ) 

Convenience routine to allocate memory in a system-independent way.

The buffer returned is page aligned. Page alignment is required for some EDT image routines and always preferred. This function uses VirtualAlloc on Windows NT/2000/XP systems, or valloc on Linux/Unix systems.

Example

        unsigned char *buf = pdv_alloc(pdv_image_size(pdv_p));

Parameters:
size the number of bytes of memory to allocate
Returns:
The address of the allocated memory, or NULL on error. If NULL, use pdv_perror to print the error.
See also:
pdv_free

Definition at line 7249 of file libpdv.c.

int pdv_bytes_per_line ( int  width,
int  depth 
)

Returns bytes per line based on width and bit depth, including depth < 8.

Parameters:
width pixels per line
depth bits per pixel
Returns:
bytes per line

Definition at line 658 of file libpdv.c.

int pdv_cl_camera_connected ( PdvDev pdv_p  ) 

Checks whether a camera is connected and turned on.

Looks for an active (changing) pixel clock from the camera, and returns 1 if detected.

Note:
This subroutine only works on EDT Camera Link boards, and only those that have base mode firmware (pdvcamlk or pdvcamlk2 11/02/2006 (rev 34) or later.
Returns:
1 if active pixel clock is detected, 0 if not detected OR not supported (not camera link). Will also return 0 if firmware does not support this feature (see above).

Definition at line 10146 of file libpdv.c.

void pdv_free ( uchar_t *  ptr  ) 

Convenience routine to free the memory allocated with pdv_alloc.

Parameters:
ptr Address of memory buffer to free.

Definition at line 7262 of file libpdv.c.

int pdv_is_atmel ( PdvDev pdv_p  ) 

Infers that this device is connected to is an Atmel camera, based on the camera_class directive.

Parameters:
pdv_p pointer to pdv device structure returned by pdv_open
Returns:
1 if device pdv_p has been setup for Atmel camera, 0 otherwise.
See also:
pdv_get_camera_class

Definition at line 8943 of file libpdv.c.

int pdv_is_cameralink ( PdvDev pdv_p  ) 

Infers that this device is connected to is a Camera Link camera (as opposed to RS-422 or LVDS parallel), based on settings from the loaded camera config file.

Generally useful only for applications that may use both Camera Link and the (older) AIA cameras, and that need to differentiate between the two. Specifically for framegrabbers, will return false (0) for simulators.

Parameters:
pdv_p device handle returned by pdv_open
Returns:
1 if Camera Link framegrabber, 0 otherwise

Definition at line 9917 of file libpdv.c.

int pdv_is_dvc ( PdvDev pdv_p  ) 

Infers that this device is connected to is a DVC camera, from settings from the loaded camera config file.

Parameters:
pdv_p pointer to pdv device structure returned by pdv_open
Returns:
1 if device pdv_p has been setup for DVC camera, else 0.

Definition at line 9511 of file libpdv.c.

int pdv_is_hamamatsu ( PdvDev pdv_p  ) 

Infers that this device is connected to is a Hamamatsu camera based on the camera class string.

Parameters:
pdv_p pointer to pdv device structure returned by pdv_open
Returns:
1 if device pdv_p has been setup for Hamamatsu camera, else 0.

Definition at line 8961 of file libpdv.c.

int pdv_is_kodak_i ( PdvDev pdv_p  ) 

Infer if it's a Redlake (formerly Roper, formerly Kodak) 'i' camera from the serial settings.

Since serial commands have changed quite a bit over the years, this subroutine should not be depended on and is only included for backwards compatability.

Parameters:
pdv_p pointer to pdv device structure returned by pdv_open
Returns:
1 if pdv_p appears setup for Redlake, 0 otherwise.

Definition at line 8919 of file libpdv.c.

int pdv_is_simulator ( PdvDev pdv_p  ) 

Infers that this device is a simulator -- either a PCI DV CLS board, or a PCIe DV C-Link with simulator FPGA loaded.

Parameters:
pdv_p device handle returned by pdv_open
Returns:
1 if a simulator, 0 otherwise

Definition at line 9947 of file libpdv.c.

void pdv_perror ( char *  err  ) 

Formats and prints a system error.

Convenience function to format and print a system error. In Linux implementations, the routine just turns around and makes a perror system call, with the errstr argument. NT implementations format and print the last error using GetLastErrorString.

Definition at line 7194 of file libpdv.c.

int pdv_update_values_from_camera ( PdvDev pdv_p  ) 

Deprecated -- Queries certain specific cameras via serial, and sets library variables for gain, black level, exposure time and binning to values based on the results of the query.

Included for backwards compatability only. The cameras supported are all older (pre-2000) cameras made by Kodak Megaplus 'i', Hamamatsu, DVC, and Atmel.

This subroutine will be removed in a future release and should not be used.

Parameters:
pdv_p pointer to pdv device structure returned by pdv_open
Returns:
0 on success, -1 on error (including if the camera is not one that is supported by this subroutine)

Definition at line 8983 of file libpdv.c.


Generated on 19 Jun 2015 by  doxygen 1.4.7