getecamimg
所属分类:网络编程
开发工具:Visual C++
文件大小:67KB
下载次数:25
上传日期:2006-11-30 13:43:50
上 传 者:
syhost
说明: ipcam的软件 Iqeye公司的IPcam,型号为300系列的
(ipcam Iqeye software company IPcam, model 300 series)
文件列表:
Makefile.in (2033, 2002-07-27)
configure (70085, 2002-06-22)
configure.in (448, 2002-06-18)
correct.c (21710, 2004-08-13)
correct.h (792, 2003-08-09)
eorc.h (1847, 2002-07-23)
getecamimg.cpp (29645, 2004-08-19)
install-sh (5598, 2001-06-21)
iqeye.cpp (34151, 2004-08-19)
iqeye.h (7726, 2003-08-09)
iqshow.cpp (13604, 2003-08-09)
iqshow.mak (1737, 2002-08-08)
makebor.bat (219, 2003-08-09)
makefile.msvc (710, 2004-07-13)
makemsvc.bat (117, 2003-08-09)
makeoid.bat (161, 2003-08-09)
md5c.c (9920, 2001-03-07)
mymd5.h (1454, 2001-03-07)
oid.cpp (1685, 2002-07-27)
sex.h (454, 1999-05-17)
streambf.cpp (249, 2001-08-15)
streambf.h (791, 2001-08-15)
udpcmn.h (11497, 2002-06-22)
x.cpp (3857, 2003-08-09)
x.h (445, 2003-08-09)
msvc (0, 2004-08-19)
msvc\iqshow.dsp (3754, 2003-08-09)
msvc\iqshow.dsw (549, 2003-08-09)
Readme file for the getecamimg sample application for the IQeye.
What is getecamimg?
-------------------
getecamimg is a sample command line application, compileable under
*nix or Windows, which demonstrates the use of the CIQeye class to
request raw images from the IQeye camera. The image data is
transferred in raw form, as opposed to getting a JPEG image with a
browser.
what is iqshow?
---------------
iqshow also demonstrates the CIQeye class, but displays the resulting
images. It also compiles under *nix and Windows.
Building under *nix
-------------------
./configure
make all
will build getecamimg under *nix systems
make iqshow
will build iqshow under *nix systems
Building under Windows
----------------------
We have sample .bat files which show how to compile under borland and
msvc compilers. They're simple one-liners. The important things to
note are that you have to compile with -DWINDOWS and include the
winsock2 library.
iqshow.mak is a Borland makefile for iqshow.
The CIQeye Class
----------------
CIQeye is a C++ class which wraps the nview protocol for speaking
to an IQeye camera. It was written to provide an easy interface for
grabbing raw images from the camera, so folks don't have to plow
through the nview protocol specification.
getecamimg.cpp demonstrates the use of this class. It also
demonstrates how to convert from the raw image to RGB data (the PPM
format).
Why use this class? Because this is the only way to get raw
image data from the camera. If you go over HTTP, you can only get JPEGs.
Quick Start Usage
-----------------
getecamimg -bin > img.raw
Will grab a raw image from and write it to file
'img.raw'.
getecamimg -ppm > img.ppm
Will grab a raw image from and write it out in PPM
(RGB) format to file 'img.ppm'.
Image Format
------------
The nview protocol grabs raw image data from the camera. Each
byte represents either a R, G, or B value, straight from the imager.
If you want to create an RGB image from this (PPM for instance), then
you'll need to convert it using the color conversion matrix which gets
sent with each frame. This matrix is the same one that the camera
uses when it generates JPEG images, so JPEGs from the camera and PPMs
from getecamimg should look about the same. See DoConvert() in
correct.c for how to do the conversion. Note that the code makes no
assumptions about how the Bayer pattern comes out of the camera - all
the information about which values are actually R, G, or B is encoded
in the conversion matrix.
Using the API
-------------
Basic usage:
int rv;
int imglen;
unsigned char *bf = (unsigned char *)malloc(MAX_COLS * MAX_ROWS);
CIQeye *iq = new CIQeye (host, "root", "system");
rv = iq->readImage (iq->SubXorg, iq->SubYorg,
iq->SubWidth, iq->SubHeight,
bf, &imglen);
delete iq;
free (bf);
The constructor opens up a socket. The default priviledged
username and password is "root" and "system." readImage() grabs a raw
frame with the given window coordinates into the user-supplied
buffer. The Subxxx variables are correspond to the default crop
window on the camera. After you grab the image, you can do anything
you want with it, then call the destructor to clean up.
CIQeye member functions
-----------------------
o CIQeye (char *ip_name, char *user = NULL, char *passwd = NULL)
Constructor for the CIQeye class.
ip_name: ip address or hostname of camera
user: username to authenticate with ("root" to authenticate
with system privileges)
password: password to authenticate with ("system" is the
default system password)
This function initializes the networking, gets authentication
credentials, image options, and image configuration from the
camera.
o ~CIQeye ()
Class destructor. Cleans everything up.
o bool readImage (int clipx, int clipy,
int clipw, int cliph,
StreamBf *imgbf,
int *imglen,
bool domask = false,
bool compressed = false,
bool correct = false);
Reads one image from the camera in raw bayer pattern form.
clipx: starting column
clipy: starting row
clipw: width
clipy: height
imgbf: buffer for image - needs to be allocated to max
possible image size by caller
imglen: receives total bytes in image
domask: true if we want a masked image
compressed: true if we want a compressed image
correct: true to enable hotpixel correction
Returns true on success, false on failure
o bool getMatrix (long *matrix)
Gets the EORC matrix from the camera. The EORC matrix is what
allows you to convert from bayer pattern to RGB.
matrix: array of longs to receive the matrix (must be
EORCMTXCNT long)
Returns true on success, false on failure
o bool setImageMask (int start_row, int num_rows,
int *starts, int *lengths)
Send an image mask to the camera.
start_row: starting row of this mask (base 0)
num_rows: number of rows in this mask
starts: array of ints which specify starting column (base 0)
lengths: array of ints which specify row length for each start
Returns true on success, false on failure
Setting an image mask is a way to get an arbitrary blob from the
camera instead of a rectangle. The protocol supports blobs with
holes in it, but this function does not. So you can specify a
disk but not a doughnut. If you set domask to true when you
readImage(), the resulting image buffer will consist of only
the pixels which match the masked area
o bool clearImageMask ()
Tells the camera to clear the image mask. You always want to
do this as part of your cleanup procedure since the image mask
takes up memory on the camera. And if you don't clear it, it
will stick around for the next guy.
Returns true on success, false on failure
o void setFlip (unsigned char flip)
Tells the camera to flip/rotate the image as per the flags
in udpcmn.h
o void setDS (unsigned char ds)
Sets the downsample factor. The image gets downsample in each
dimension by ds.
o void setSharpen (unsigned short sharpen)
Sets the sharpening factor on the camera. The camera does not
sharpen for you - this just affects the EORC sharpening values
for when you sharpen locally.
o void setSharpNoI (bool val)
Tells the camera to send sharpen values for a non-interpolated
image (if val == true) or an interpolated image (val == false).
By default, the camera sends sharpening values assuming that
you will interpolate. If you are going to us a non-interpolate
color correction, you should ask for the non-interpolate
sharpening scalars.
o void setExtraProc (unsigned char extra)
This sets the value that is put in the extra processing field
of the image request. Use this if you have custom firmware
which registers an extra processing hook into the nview
protocol (see oem.c in the partner source code).
o void setGamma (unsigned char gamma)
Sets the gamma value sent with the image request. Currently you
have to gamma correct locally, so this doesn't do any good.
o void setManualGain (int manual)
Determines how setGainPercent() behaves.
manual: if 0, turns on auto gain, else turns on manual gain
Returns true on success, false on failure
o bool setGainPercent (int gain_percent)
Sets gain on the camera as a percentage from 0 (lowest) to 100
(highest).
If gain is manual, gain in the camera is held to reflect
gain_percent.
If gain is auto, the target gain value is set to gain_percent
gain_percent: percent from 0 to 100
Returns true on success, false on failure
o bool getGainPercent (int *gain_percent)
Gets the gain from the camera, expressed as a percent from 0 to
100.
If gain is manual, this is the hold value.
If gain is auto, this is the target value.
Returns true on success, false on failure
o unsigned long getTimestamp ()
Returns the timestamp from the last image read. Every tick of
this timer is 10ms and is relative, not absolute (wall) time.
o unsigned short getMaxWidth ()
Returns the maximum imager width
o unsigned short getMaxHeight ()
Returns the maximum imager height
o unsigned short getLastWidth ()
Returns the width of the last image read
o unsigned short getLastHeight ()
Return the height of the last image read
o bool GetOid (const char *oid, char *val)
Get a runtime OID value from the camera.
oid: OID to get the value of
value: where to put the value
OIDs and the OID table are documented elsewhere.
Returns true on success, false on failure
o bool SetOid (const char *oid, const char *val)
Set a runtime OID on the camera
oid: OID to set
value: new value for the OID
Returns true on success, false on failure
o const char *strerror (int code)
Converts a failure code to a meaningful string.
code: FailReason
CIQeye member variables
-----------------------
o int FailReason
Last error code. See iqeye.h for values, or call
iq->strerror (iq->FailReason) for a string.
o unsigned short SubWidth
Width of the camera's crop window
o unsigned short SubHeight
Height of the camera's crop window
o unsigned short SubXorg
Left coordinate of the camera's crop window
o unsigned short SubYorg
Top coordinate of the camera's crop window
o unsigned short MaxWidth
Maximum window width
o unsigned short MaxHeight
Maximum window height
o unsigned short LastWidth
Width of last image
o unsigned short LastHeight
Height of last image
o unsigned char CurGamma
Camera's current gamma value
o int ExtraLen
Length of any meta data delivered with last image
o StreamBf *ExtraBf
Extra data (if any) delivered with last image
近期下载者:
相关文件:
收藏者: