summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/camera/cmd/capture.cpp141
-rw-r--r--noncore/multimedia/camera/cmd/cmd.pro6
2 files changed, 142 insertions, 5 deletions
diff --git a/noncore/multimedia/camera/cmd/capture.cpp b/noncore/multimedia/camera/cmd/capture.cpp
index e34c4e3..7960bbb 100644
--- a/noncore/multimedia/camera/cmd/capture.cpp
+++ b/noncore/multimedia/camera/cmd/capture.cpp
@@ -1,9 +1,146 @@
1/**********************************************************************
2** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved.
3**
4** This file is part of Opie Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14**********************************************************************/
15
16#include "zcameraio.h"
17#include "imageio.h"
18#include "avi.h"
19
20#include <qfile.h>
21#include <qimage.h>
22#include <opie2/oapplication.h>
23
24#include <assert.h>
25#include <sys/types.h>
26#include <sys/stat.h>
27#include <fcntl.h>
28#include <string.h>
29#include <errno.h>
30#include <unistd.h>
1#include <stdio.h> 31#include <stdio.h>
2 32
33#define CAPTUREFILE "/tmp/capture.dat"
34#define OUTPUTFILE "/tmp/output.avi"
35
36int captureX = 240;
37int captureY = 320;
38int quality = 75;
39QString flip = "A";
40int zoom = 1;
41QString format = "JPG";
42QString name;
43
44int performCapture();
45
46void usage()
47{
48 printf( "Usage: ./capture [options] filename\n\n" );
49 printf( " -x xresolution (dividable by 16) [default=240]\n" );
50 printf( " -y xresolution (dividable by 16) [default=320]\n" );
51 printf( " -q quality (10-100) [default=75]\n" );
52 printf( " -f flip (A=auto, X, Y, *=both) [default=Auto]\n" );
53 printf( " -o output format (JPG,BMP,PNG) [default=JPG]\n" );
54 printf( " -z zoom (1-2) [default=1]\n" );
55}
56
3int main( int argc, char** argv ) 57int main( int argc, char** argv )
4{ 58{
5 printf( "Not yet implemented.\n" ); 59 OApplication* a = new OApplication( argc, argv, "opie-camera" );
6 return 0; 60
61 if ( argc < 2 )
62 {
63 usage();
64 return -1;
65 }
66
67 int captureX = 240;
68 int captureY = 320;
69 QString flip = "A";
70
71 #define I_HATE_WRITING_HARDCODED_PARSES
72
73 int i = 1;
74 while ( i < argc )
75 {
76 // check for filename
77 if ( argv[i][0] != '-' )
78 {
79 if ( argc != i+1 )
80 {
81 usage();
82 return -1;
83 }
84 else
85 {
86 name = argv[i];
87 break;
88 }
89 }
90 else
91 {
92 i++;
93 if ( argc == i )
94 {
95 usage();
96 return -1;
97 }
98 switch ( argv[i-1][1] )
99 {
100 case 'x': captureX = QString( argv[i] ).toInt(); break;
101 case 'y': captureY = QString( argv[i] ).toInt(); break;
102 case 'z': zoom = QString( argv[i] ).toInt(); break;
103 case 'o': format = QString( argv[i] ); break;
104 case 'q': quality = QString( argv[i] ).toInt(); break;
105 case 'f': flip = QString( argv[i] )[0]; break;
106 default: usage(); return -1;
107 }
108 i++;
109 }
110
111 #undef I_HATE_WRITING_HARDCODED_PARSES
112 }
113
114 if ( !ZCameraIO::instance()->isOpen() )
115 {
116 printf( "Error: Can't detect your camera. Exiting.\n" );
117 return -1;
118 }
119 return performCapture();
7} 120}
8 121
9 122
123int performCapture()
124{
125 printf( "Capturing %dx%d Image [%s] q%d z%d --> %s\n", captureX,
126 captureY,
127 (const char*) format,
128 quality,
129 zoom,
130 (const char*) name );
131
132 QImage i;
133 ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i );
134 QImage im = i.convertDepth( 32 );
135 bool result = im.save( name, format, quality );
136 if ( !result )
137 {
138 printf( "QImageio-Problem while writing.\n" );
139 return -1;
140 }
141 else
142 {
143 printf( "Ok.\n" );
144 }
145}
146
diff --git a/noncore/multimedia/camera/cmd/cmd.pro b/noncore/multimedia/camera/cmd/cmd.pro
index 68ee907..3b1aaa6 100644
--- a/noncore/multimedia/camera/cmd/cmd.pro
+++ b/noncore/multimedia/camera/cmd/cmd.pro
@@ -1,18 +1,18 @@
1MOC_DIR = ./moc 1MOC_DIR = ./moc
2OBJECTS_DIR = ./obj 2OBJECTS_DIR = ./obj
3DESTDIR = $(OPIEDIR)/bin 3DESTDIR = $(OPIEDIR)/bin
4TEMPLATE = app 4TEMPLATE = app
5CONFIG = qt warn_on debug 5CONFIG = qt warn_on debug
6 6
7HEADERS = 7HEADERS =
8 8
9SOURCES = capture.cpp 9SOURCES = capture.cpp
10 10
11INCLUDEPATH += $(OPIEDIR)/include 11INCLUDEPATH += $(OPIEDIR)/include ../lib
12DEPENDPATH += $(OPIEDIR)/include 12DEPENDPATH += $(OPIEDIR)/include ../lib
13LIBS += -lqpe -lopiecore2 13LIBS += -lqpe -lopiecore2 -lopiecam
14INTERFACES = 14INTERFACES =
15TARGET = capture 15TARGET = capture
16 16
17include ( $(OPIEDIR)/include.pro ) 17include ( $(OPIEDIR)/include.pro )
18 18