This repository has been archived by the owner on Apr 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 148
/
roadmap_camera_defs.h
157 lines (135 loc) · 4.56 KB
/
roadmap_camera_defs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/* roadmap_camera_defs.h - The camera management related definitions
*
* LICENSE:
*
* Copyright 2009, Waze Ltd
* Alex Agranovich
*
* This file is part of RoadMap.
*
* RoadMap 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 2 of the License, or
* (at your option) any later version.
*
* RoadMap 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 RoadMap; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef INCLUDE__ROADMAP_CAMERA_DEFS__H
#define INCLUDE__ROADMAP_CAMERA_DEFS__H
#ifdef __cplusplus
extern "C" {
#endif
// This type represents the quality level for the compressed picture
// low quality = maximum compression
typedef enum
{
quality_low = 0x0,
quality_medium,
quality_high
} CameraImageQuality;
// Camera image file format
typedef enum
{
file_fmt_JPEG = 0x0,
file_fmt_PNG,
file_fmt_BMP,
file_fmt_RAW
} CameraImageFileFmt;
// Pixel format for camera image buffers
typedef enum
{
pixel_fmt_bgra_8888 = 0x0,
pixel_fmt_rgba_8888,
pixel_fmt_rgb_565,
pixel_fmt_rgb_888,
pixel_fmt_jpeg,
pixel_fmt_png
} CameraImagePixelFmt;
// Camera image file attributes
typedef struct
{
int width;
int height;
CameraImageQuality quality;
CameraImageFileFmt file_format;
char* folder;
char* file;
} CameraImageFile;
// Camera image buffer attributes and pointer to the image data
typedef struct
{
int width;
int height;
CameraImagePixelFmt pixfmt; // Pixel format
unsigned char* buf; // The buffer pointer. Pay attention to the 1-byte alignment
} CameraImageBuf;
// Asynchronous capture callback context
typedef struct
{
CameraImageFile image_file;
CameraImageBuf image_thumbnail;
const void* callback_data; // Data provided by the callback supplier
} CameraImageCaptureContext;
// Asynchronous capture callback
typedef int (* CameraImageCaptureCallback) ( CameraImageCaptureContext* context, int res );
// Configuration entries
#define CFG_CATEGORY_CAMERA_IMG ( "Camera Image" )
#define CFG_ENTRY_CAMERA_IMG_WIDTH ( "Width" )
#define CFG_ENTRY_CAMERA_IMG_HEIGHT ( "Height" )
#define CFG_ENTRY_CAMERA_IMG_QUALITY ( "Quality" )
#define CFG_ENTRY_CAMERA_IMG_SERVER ( "Web-Service Address" )
#define CFG_ENTRY_CAMERA_IMG_URL_PREFIX ( "Download Prefix" )
// Default configuration values for image ( Portrait 3:4 aspect ratio )
#define CFG_CAMERA_IMG_WIDTH_DEFAULT 320
#define CFG_CAMERA_IMG_HEIGHT_DEFAULT 240
#define CFG_CAMERA_IMG_QUALITY_DEFAULT 1 //quality_medium
#define CFG_CAMERA_IMG_SERVER_DEFAULT ""
#define CFG_CAMERA_IMG_URL_PREFIX_DEFAULT "http://waze.photos.s3.amazonaws.com/thumbs/thumb347_"
// Camera image thumbnail default values
#define CFG_CAMERA_THMB_WIDTH_DEFAULT (140)
#define CFG_CAMERA_THMB_HEIGHT_DEFAULT (105)
// Image ID length (bytes)
#define ROADMAP_IMAGE_ID_LEN (36)
// Downloaded images file suffix
#define ROADMAP_IMG_DOWNLOAD_FILE_SUFFIX (".jpg")
// Initializers
#define CAMERA_IMG_FILE_INIT( _this, _width, _height, _quality, _fmt, _folder, _file ) \
{ \
(_this).width = _width; \
(_this).height = _height; \
(_this).quality = _quality; \
(_this).file_format = _fmt; \
(_this).folder = _folder; \
(_this).file = _file; \
}
#define CAMERA_IMG_BUF_INIT( _this, _width, _height, _fmt, _buf ) \
{ \
(_this).width = _width; \
(_this).height = _height; \
(_this).pixfmt = _fmt; \
(_this).buf = _buf; \
}
#define CAMERA_IMG_FILE_SET_PATH( _this, _folder, _file ) \
{ \
(_this).folder = strdup( _folder ); \
(_this).file = strdup( _file ); \
}
#define CAMERA_IMG_BUF_SET( _this, _buf ) \
{ \
(_this).buf = _buf; \
}
#define CAMERA_IMG_FILE_DFLT { CFG_CAMERA_IMG_WIDTH_DEFAULT, CFG_CAMERA_IMG_HEIGHT_DEFAULT, \
quality_medium, file_fmt_JPEG, "", "" }
#define CAMERA_THMB_BUF_DFLT { CFG_CAMERA_THMB_WIDTH_DEFAULT, CFG_CAMERA_THMB_WIDTH_DEFAULT, \
pixel_fmt_rgba_8888, NULL }
#ifdef __cplusplus
}
#endif
#endif /* INCLUDE__ROADMAP_CAMERA_DEFS__H */