Player
Frontpage
Contents
User
Installation
Quick start
Supported devices
Tutorials
Utilities
Client libraries
FAQ
Help
Developer
Architecture
libplayercore
libplayerinterface
interfaces
libplayerdrivers
drivers
libplayercommon
libplayersd
libplayertcp
libplayerxdr
TODO
Online
Homepage
Download
Project
Bugs
Help
server
drivers
mixed
cmucam2
camera.h
1
/*
2
* Player - One Hell of a Robot Server
3
* Copyright (C) 2000
4
* Pouya Bastani, Richard Vaughan, Radu Bogdan Rusu
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
*
20
*/
21
22
#ifndef CAMERA_H_
23
#define CAMERA_H_
24
25
#ifdef __cplusplus
26
extern
"C"
27
{
28
#endif
29
30
#include <fcntl.h>
31
#include <termios.h>
32
#include <stdio.h>
33
#include <time.h>
34
#include <string.h>
35
#include <stdlib.h>
36
#include <unistd.h>
37
38
/* These should NOT be redefined. */
39
//typedef unsigned int uint32_t;
40
//typedef unsigned short uint16_t;
41
//typedef unsigned char uint8_t;
42
43
/* Instead #include playerconfig.h, which gets them in a portable way */
44
#include "playerconfig.h"
45
46
47
/**************************************************************************
48
*** CONSTANST ***
49
**************************************************************************/
50
#define IMAGE_WIDTH 174 // the width of the frame camera sends
51
#define IMAGE_HEIGHT 143 // the height of the frame camera sends
52
#define CONTRAST 5 // camera's contrast register #
53
#define BRIGHTNESS 6 // camera's brightness register #
54
#define COLORMODE 18 // camera's colormode register #
55
#define RGB_AWT_ON 44 // camera's RGB auto white balance on
56
#define RGB_AWT_OFF 40 // camera'sRGB auto white balance off
57
#define YCRCB_AWT_ON 36 // camera'sYCrCb auto white balance on
58
#define YCRCB_AWT_OFF 32 // camera'sYCrCb auto white balance off
59
#define AUTOGAIN 19 // camera's autogain register #
60
#define AUTOGAIN_ON 33 // camera's autogain on
61
#define AUTOGAIN_OFF 32 // camera's autogain off
62
#define ZERO_POSITION 128 // servos' middle position as defiend by camera
63
#define MIN_RGB 16 // camera's min rgb value
64
#define MAX_RGB 240 // camera's max rgb value
65
#define T_PACKET_LENGTH 50 // max length of T packet that camera returns
66
#define F_PACKET_LENGTH 37474 // max length of F packet that camera returns
67
68
69
/**************************************************************************
70
*** T PACKET ***
71
**************************************************************************/
72
typedef
struct
// camera's output packet for tracking blobs
73
{
74
int
middle_x, middle_y;
// the blob entroid (image coords)
75
int
left_x;
// the left most corner's x value
76
int
left_y;
// the left msot corner's y value
77
int
right_x;
// the right most corner's x vlaue
78
int
right_y;
// the right most corner's y value
79
int
blob_area;
// number of pixles int he tracked regtion,
80
// scaled and capped at 255:(pixles+4)/8
81
int
confidence;
// the (# of pixles/area)*256 of the bounded
82
// rectangle and capped at 255
83
}
packet_t
;
84
85
/**************************************************************************
86
*** F PACKET ***
87
**************************************************************************/
88
typedef
struct
89
{
90
int
r, g, b;
91
}
rgb_type
;
92
93
typedef
struct
94
{
95
int
rowbyte;
96
rgb_type
rgb
[IMAGE_WIDTH];
97
}
row_type
;
98
99
typedef
struct
100
{
101
int
first;
102
int
xsize, ysize;
103
row_type
rows[IMAGE_HEIGHT];
104
int
last;
105
}
packet_f
;
106
107
/**************************************************************************
108
*** IMAGER CONFIG ***
109
**************************************************************************/
110
typedef
struct
// camera's internal register controlling image quality
111
{
112
uint8_t subtype;
// must be PLAYER_BLOBFINDER_REQ_SET_IMAGER_PARAMS.
113
int16_t brightness;
// contrast: -1 = no change. (0-255)
114
int16_t contrast;
// brightness: -1 = no change. (0-255)
115
int8_t colormode;
// color mode: -1 = no change.
116
// 0 = RGB/auto white balance Off,
117
// 1 = RGB/AutoWhiteBalance On,
118
// 2 = YCrCB/AutoWhiteBalance Off,
119
// 3 = YCrCb/AWB On)
120
int8_t autogain;
// auto gain: -1 = no change.
121
// 0 = off, o
122
// 1 = on.
123
}
imager_config
;
124
125
/**************************************************************************
126
*** CONFIG CONFIG ***
127
**************************************************************************/
128
typedef
struct
129
{
130
uint8_t subtype;
// must be PLAYER_BLOBFINDER_REQ_SET_COLOR.
131
int16_t rmin, rmax;
// RGB minimum and max values (0-255)
132
int16_t gmin, gmax;
133
int16_t bmin, bmax;
134
}
color_config
;
135
136
/**************************************************************************
137
*** RGB ***
138
**************************************************************************/
139
typedef
struct
// RGB values
140
{
141
int
red;
142
int
green;
143
int
blue;
144
}
rgb
;
145
146
/**************************************************************************
147
*** CONFIG CONFIG ***
148
**************************************************************************/
149
typedef
struct
// camera's image
150
{
151
int
width;
152
int
height;
153
rgb
**pixel;
154
}
image
;
155
156
157
/**************************************************************************
158
*** FUNCTION PROTOTYPES ***
159
**************************************************************************/
160
int
get_t_packet(
int
fd,
packet_t
*tpacket);
161
int
set_imager_config(
int
fd,
imager_config
ic);
162
int
get_bytes(
int
fd,
char
*buf,
size_t
len);
163
int
open_port(
char
*devicepath);
164
void
close_port(
int
fd);
165
void
read_t_packet(
int
fd,
char
*tpackChars);
166
int
read_f_packet (
int
fd,
char
*fpackChars);
167
int
set_t_packet(
packet_t
*tpacket,
char
tpack_chars[] );
168
int
set_f_packet (
packet_f
*fpacket,
char
fpack_chars[],
int
chan_num);
169
int
set_servo_position(
int
fd,
int
servo_num,
int
angle);
170
int
get_servo_position(
int
fd,
int
servo_num);
171
void
stop_tracking(
int
fd);
172
int
write_check(
int
fd,
char
*msg,
int
respond_size);
173
int
poll_mode(
int
fd,
int
on);
174
void
make_command(
char
*cmd,
int
*n,
size_t
size,
char
*fullCommand);
175
int
auto_servoing(
int
fd,
int
on);
176
void
track_blob(
int
fd,
color_config
cc);
177
int
read_image (
int
fd,
int
chan_num,
packet_f
*fpacket);
178
179
#ifdef __cplusplus
180
}
181
#endif
182
183
#endif
imager_config
Definition:
camera.h:110
row_type
Definition:
camera.h:93
rgb_type
Definition:
camera.h:88
image
Definition:
camera.h:149
packet_t
Definition:
camera.h:72
packet_f
Definition:
camera.h:99
rgb
Definition:
cmvision.h:105
color_config
Definition:
camera.h:128
Generated on Wed Sep 2 2020 16:39:27 for Player by
1.8.13