summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschodet2003-05-22 18:05:25 +0000
committerschodet2003-05-22 18:05:25 +0000
commit028befd70da61c3468149a1f1afa3d9eaf4369c7 (patch)
tree253d937265197995715102411af4e3af883f6875
parentd201c6b9e46b79b6dabb5a7cd753b95c108c0915 (diff)
Ajout de Dumpimage
Réglage des paramètres de la camera.
-rw-r--r--2003/i/buzz/src/camera/Makefile.defs7
-rw-r--r--2003/i/buzz/src/camera/camera.cc38
-rw-r--r--2003/i/buzz/src/camera/camera.h2
-rw-r--r--2003/i/buzz/src/camera/dumpimage.cc34
-rw-r--r--2003/i/buzz/src/camera/test_camera.cc20
5 files changed, 88 insertions, 13 deletions
diff --git a/2003/i/buzz/src/camera/Makefile.defs b/2003/i/buzz/src/camera/Makefile.defs
index 060aaaa..6ef85b3 100644
--- a/2003/i/buzz/src/camera/Makefile.defs
+++ b/2003/i/buzz/src/camera/Makefile.defs
@@ -1,7 +1,10 @@
-TARGETS += test_camera
-test_camera_SOURCES = camera.cc test_camera.cc vision.a erreur.a -lppm
+TARGETS += test_camera dumpimage
+test_camera_SOURCES = camera.cc test_camera.cc erreur.a
+dumpimage_SOURCES = camera.cc dumpimage.cc erreur.a
camera_a_SOURCES = camera.cc
+dumpimage: $(dumpimage_SOURCES:%.cc=%.o)
+
test_camera: $(test_camera_SOURCES:%.cc=%.o)
camera.a: ${camera_a_SOURCES:%.cc=camera.a(%.o)}
diff --git a/2003/i/buzz/src/camera/camera.cc b/2003/i/buzz/src/camera/camera.cc
index 3982c7e..e9a7f60 100644
--- a/2003/i/buzz/src/camera/camera.cc
+++ b/2003/i/buzz/src/camera/camera.cc
@@ -9,6 +9,8 @@
#include <fcntl.h>
#include <unistd.h>
#include <iostream> // Debug.
+#include <iomanip> //
+#include <fstream>
#define CAM_FILE "/dev/robotcam"
@@ -20,14 +22,36 @@ Camera::Camera ()
if (m_fd == -1)
throw ErreurFatale ("Impossible d'ouvrir le périphérique de la"
" camera.\n");
+ // Paramètre la camera.
+ sccb_io param;
+ ifstream rc ("rc/camera");
+ int addr, data;
+ while (!rc.eof ())
+ {
+ rc >> hex >> addr >> hex >> data;
+ if (rc.good ())
+ {
+ param.addr = addr; param.data = data;
+ cout << "camera sccbwrite 0x" << hex << addr << " 0x" << data <<
+ endl;
+ ioctl (m_fd, CAM_SCCBWRITE, &param);
+ }
+ }
+ // Affiche les paramètres.
+ cout << hex << "camera sccbdump";
+ for (addr = 0; addr < 0x50; ++addr)
+ {
+ if (!(addr % 16)) cout << endl;
+ param.addr = addr;
+ ioctl (m_fd, CAM_SCCBREAD, &param);
+ data = param.data;
+ cout << setw (2) << setfill ('0') << data << ' ';
+
+ }
+ cout << endl << dec;
// Paramètre la taille de frame.
- m_frameSize = m_w * m_h;
- ioctl (m_fd, CAM_SETFRAMESIZE, m_frameSize);
- // Lance le dma ?
- unsigned int image;
- ::read (m_fd, &image, 0);
- char t;
- cin >> t;
+ m_frameSize = m_w * m_h * 3;
+ ioctl (m_fd, CAM_SETFRAMESIZE, &m_frameSize);
}
// Destructeur.
diff --git a/2003/i/buzz/src/camera/camera.h b/2003/i/buzz/src/camera/camera.h
index 5c15a88..954980c 100644
--- a/2003/i/buzz/src/camera/camera.h
+++ b/2003/i/buzz/src/camera/camera.h
@@ -7,7 +7,7 @@
class Camera
{
int m_fd;
- static const int m_w = 352, m_h = 280;
+ static const int m_w = 352, m_h = 288;
int m_frameSize;
public:
// Constructeur.
diff --git a/2003/i/buzz/src/camera/dumpimage.cc b/2003/i/buzz/src/camera/dumpimage.cc
new file mode 100644
index 0000000..6692c26
--- /dev/null
+++ b/2003/i/buzz/src/camera/dumpimage.cc
@@ -0,0 +1,34 @@
+// dumpimage.cc
+// buzz - Programme du robot Efrei Robotique I1-I2 2003
+// Copyright (C) 2003 Nicolas Schodet
+//
+#include "camera.h"
+
+#include <iomanip>
+#include <unistd.h>
+
+int
+main (int argc, char **argv)
+{
+ Camera cam;
+ int w, h;
+ cam.getSize (w, h);
+ unsigned char *image = new unsigned char[w * h];
+ cout << hex;
+ int j = 0;
+ int pixel;
+ while (1)
+ {
+ cout << dec << "\n- " << j++ << hex << " ---------";
+ cam.read (image);
+ for (int i = 0; i < 256; ++i)
+ {
+ if (!(i % 16))
+ cout << endl;
+ pixel = image[i];
+ cout << setw (2) << setfill ('0') << pixel << ' ';
+ }
+ }
+ delete image;
+ return 0;
+}
diff --git a/2003/i/buzz/src/camera/test_camera.cc b/2003/i/buzz/src/camera/test_camera.cc
index 130d53e..1868ad5 100644
--- a/2003/i/buzz/src/camera/test_camera.cc
+++ b/2003/i/buzz/src/camera/test_camera.cc
@@ -3,12 +3,26 @@
// Copyright (C) 2003 Nicolas Schodet
//
#include "camera.h"
-#include "vision/image.h"
+
+#include <fstream>
int
main (int argc, char **argv)
{
Camera cam;
- Image image (cam, 0);
- image.dump (argc == 2 ? argv[1] : "test.ppm");
+ ofstream o0 (argc >= 2 ? argv[1] : "camera0.raw");
+ ofstream o1 (argc >= 3 ? argv[2] : "camera1.raw");
+ ofstream o2 (argc == 4 ? argv[3] : "camera2.raw");
+ int w, h;
+ cam.getSize (w, h);
+ unsigned char *image = new unsigned char[w * h * 3];
+ cam.read (image);
+ o0.write (image, w * h * 3);
+ o0.close ();
+ cam.read (image);
+ o1.write (image, w * h * 3);
+ o1.close ();
+ cam.read (image);
+ o2.write (image, w * h * 3);
+ o2.close ();
}