summaryrefslogtreecommitdiff
path: root/2003/i/buzz/src/camera/test_camera.cc
diff options
context:
space:
mode:
authorschodet2003-05-26 08:52:09 +0000
committerschodet2003-05-26 08:52:09 +0000
commitcb1085dbb78af63faae1ead1fd630d8bcaf8657b (patch)
tree9eb347cca968ad3517a0495603dbacb90f1eb9f5 /2003/i/buzz/src/camera/test_camera.cc
parenta47797ded74f6aa8e4193eff4c05d1df415c3c6a (diff)
Modification des param├Ętres w/h/d
Diffstat (limited to '2003/i/buzz/src/camera/test_camera.cc')
-rw-r--r--2003/i/buzz/src/camera/test_camera.cc43
1 files changed, 17 insertions, 26 deletions
diff --git a/2003/i/buzz/src/camera/test_camera.cc b/2003/i/buzz/src/camera/test_camera.cc
index b81f1dc..11dac93 100644
--- a/2003/i/buzz/src/camera/test_camera.cc
+++ b/2003/i/buzz/src/camera/test_camera.cc
@@ -15,9 +15,9 @@ main (int argc, char **argv)
try
{
Camera cam;
- int w, h;
- cam.getSize (w, h);
- unsigned char *image = new unsigned char[w * h];
+ int w, h, d;
+ cam.getSize (w, h, d);
+ unsigned char *image = new unsigned char[w * h * d];
unsigned char *image2 = new unsigned char[w * h * 3];
for (int i = 0; i < 10; ++i)
{
@@ -25,35 +25,26 @@ main (int argc, char **argv)
sprintf (s, "camera%d.gray", i);
ofstream o (s);
while (cam.read (image) == 0) sleep (1);
- o.write (image, w * h);
+ o.write (image, w * h * d);
o.close ();
- for (int j = 0; j < w * h; j += 4)
+ if (d == 4)
{
- image2[j * 3] = image[j + 2];
- image2[j * 3 + 1] = image[j + 1];
- image2[j * 3 + 2] = image[j];
- image2[(j + 1) * 3] = image[j + 2];
- image2[(j + 1) * 3 + 1] = image[j + 1];
- image2[(j + 1) * 3 + 2] = image[j];
- image2[(j + 2) * 3] = image[j + 2];
- image2[(j + 2) * 3 + 1] = image[j + 1];
- image2[(j + 2) * 3 + 2] = image[j];
- image2[(j + 3) * 3] = image[j + 2];
- image2[(j + 3) * 3 + 1] = image[j + 1];
- image2[(j + 3) * 3 + 2] = image[j];
+ for (int j = 0; j < w * h; ++j)
+ {
+ image2[j * 3] = image[j * 4 + 2];
+ image2[j * 3 + 1] = image[j * 4 + 1];
+ image2[j * 3 + 2] = image[j * 4];
+ }
+ sprintf (s, "camera%d.rgb", i);
+ o.open (s);
+ o.write (image2, w * h * 3);
+ o.close ();
}
- sprintf (s, "camera%d.rgb", i);
- o.open (s);
- o.write (image2, w * h * 3);
- o.close ();
- for (int j = 0; j < w * h; j += 4)
+ for (int j = 0; j < w * h; ++j)
{
- int t = (int) image[j + 2] >> 2 - (int) image[j + 1] >> 2;
+ int t = (int) image[j * 4 + 2] >> 2 - (int) image[j * 4 + 1] >> 2;
t = t > 0 ? t : -t;
image2[j] = t;
- image2[j + 1] = t;
- image2[j + 2] = t;
- image2[j + 3] = t;
}
sprintf (s, "camera%d.diff.gray", i);
o.open (s);