summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjaromil <jaromil@383723c8-4afa-0310-b8a8-b1afb83214fc>2006-07-25 14:14:30 (GMT)
committer Jaromil <jaromil@dyne.org>2008-06-26 15:23:29 (GMT)
commitc0d77d850210516c448deb7d6386d777e1fc9a8e (patch)
treef89f6d3b8571dc7320458542d8549070e6e62e9e
parent40bcb3a0e84f03952e1b51b6e77f0f877b91a1d4 (diff)
new 1.0 release including fixes by Blended for wider webcam support
git-svn-id: svn://dyne.org/rastasoft/hasciicam@766 383723c8-4afa-0310-b8a8-b1afb83214fc
-rw-r--r--hasciicam/AUTHORS1
-rw-r--r--hasciicam/ChangeLog22
-rw-r--r--hasciicam/README32
-rw-r--r--hasciicam/TODO22
-rw-r--r--hasciicam/configure.in2
-rw-r--r--hasciicam/hasciicam.18
-rw-r--r--hasciicam/hasciicam.c130
7 files changed, 105 insertions, 112 deletions
diff --git a/hasciicam/AUTHORS b/hasciicam/AUTHORS
index 69f0369..551b995 100644
--- a/hasciicam/AUTHORS
+++ b/hasciicam/AUTHORS
@@ -13,4 +13,5 @@
# rapid - security and bugfixes
# alessandro preite martinez - sgi irix support (0.9)
# thomas pfau - ftp library
+# blended - wider webcam support
diff --git a/hasciicam/ChangeLog b/hasciicam/ChangeLog
index 73ebe0b..65ca628 100644
--- a/hasciicam/ChangeLog
+++ b/hasciicam/ChangeLog
@@ -1,23 +1,5 @@
arg. i never kept a ChangeLog of this software
-anyway this last release fix an important bug
-
-hasciicam wasn't working on recent linux kernels, no way.
-
-if you had a bad experience in trying it out before, now it should work.
-
-only philips webcams are still not supported, better said all webcams
-using a pwc driver. i'll try to find the time to fix it, meanwhile you can use this hacked version:
-http://www.phrat.de/hasciicam-pwc-0.2.tar.gz
-but you may experience some problems with the ftp code...
-
-in fact also the ftp code of this hasciicam is working better: it has been substituted with ftplib and now passive mode is supported from the commandline
-
-also the manual has been updated.
-
-have phun :)
-
--- jaromil http://rastasoft.org
-
-anyway this last release includes an important fix: in fact hasciicam wasn't working with the latest kernel serie, since grab is limited to some YUV formats by all the video4linux drivers around (it was about Alan Cox observation of keeping YUV->RGB conversion code out of the kernel, delivering it to user space, IMHO totally right).
+this last release fixes support for several webcams
+thanks to blended for it!
diff --git a/hasciicam/README b/hasciicam/README
index cbb91e8..fad9baf 100644
--- a/hasciicam/README
+++ b/hasciicam/README
@@ -3,8 +3,7 @@
888888 dP__Yb o.`Y8b Yb 88 88 Yb dP__Yb 88YbdP88
88 88 dP""""Yb 8bodP' YboodP 88 88 YboodP dP""""Yb 88 YY 88
[ (h)ascii for the masses! ]
- version 0.9.1 codename RASTASOFT
- by jaromil
+ version 1.0 codename ASCII ROOTS
Hasciicam makes it possible to have live ascii video on the web. It
captures video from a tv card and renders it into ascii, formatting the
@@ -28,24 +27,11 @@ aalib - that's the great lib that makes possible ascii rendering
if your distribution does'nt includes it, you can fetch it
from the hasciicam webpage.
-video4linux driver - depending on your card - stable comes as a kernel module
- bttv :: http://www.metzlerbros.de/bttv.html
- buz :: http://www.munich-vision.de/buz
- usb cams :: http://www.linux-usb.org
-
-i'm using hasciicam with a wintv hauppage card (bttv brooktree)
-using as a driver the bttv one coming with the 2.4.x kernel series
-
-i also had success with logitech/dexxa usb cams, using the mod_quickcam
-module available at http://qce-ga.sf.net
+running it:
people reported success with several pci and usb devices, refer to
video4linux documentation for further informations
-at the moment hasciicam DOES NOT WORKS with PHILIPS WEBCAMS (and any
-other webcam using the pwc driver). help is needed with YUV420P
-grabbing to make it work - mail jaromil /@/ dyne.org for suggestions.
-
---
DOCUMENTATION
@@ -62,7 +48,7 @@ ADDITIONAL CREDITS
code snippets hacks and ideas have been contributed by:
jan hubicka and the aalibcrew, gerdknorr, mathop, augustonero, boffh,
martin guy, pbm, megabug, rat, rapid, alessandro preite martinez, hks1,
- thomas pfau, knorke, dr.meccoi
+ thomas pfau, knorke, blended
special thanks to:
# LOA hacklab milano :: http://loa.hacklab.it
@@ -77,20 +63,12 @@ special thanks to:
# FREAKNET medialab catania :: http://freaknet.org
for knowledge, place, sun and connectivity under the vulcano!
----
-
-DISCUSSION
-
-feel free to join the hasciicam@dyne.org mailinglist to discuss
-bugs, development of new features and support for new devices.
-
-have phun!
--
jaromil dyne.org rasta coder http://rastasoft.org
dyne:bolic GNU/Linux liveCD http://dynebolic.org
- MuSE Streamer v0.8.1 http://muse.dyne.org
- FreeJ v0.5 - free the veejay! http://freej.org
+ MuSE Streamer http://muse.dyne.org
+ FreeJ - free the veejay! http://freej.org
FARAH in Palestine http://farah.dyne.org
diff --git a/hasciicam/TODO b/hasciicam/TODO
index 5201459..a31efb9 100644
--- a/hasciicam/TODO
+++ b/hasciicam/TODO
@@ -1,20 +1,6 @@
-implement YUV420P grabbing to support pwc driver
-how to recognize pwc webcams:
-
-IsPhilips = FALSE;
- if (ioctl(cam_fd, VIDIOCGCAP, &vcap) < 0)
- return;
- if (sscanf(vcap.name, "Philips %d webcam", &type) < 1) {
- /* No match yet; try the PROBE */
- if (ioctl(cam_fd, VIDIOCPWCPROBE, &probe) == 0)
- if (!strcmp(vcap.name == probe.name))
- IsPhilips = TRUE;
- }
- else
- IsPhilips = TRUE;
-
-
-and some other ideas i'd love to find the time to realize or at least to
-write about in this TODO file
+- code cleanup and modularization
+- libcaca rendering
+- record and playback of hascii movies
+- encoded streaming
diff --git a/hasciicam/configure.in b/hasciicam/configure.in
index ec0ce93..b09e16c 100644
--- a/hasciicam/configure.in
+++ b/hasciicam/configure.in
@@ -9,7 +9,7 @@ AC_PROG_INSTALL
dnl Setup for automake
AM_SANITY_CHECK
-AM_INIT_AUTOMAKE(HasciiCam, 0.9.1)
+AM_INIT_AUTOMAKE(HasciiCam, 1.0)
AM_CONFIG_HEADER(config.h)
dnl Get the operating system and version number...
diff --git a/hasciicam/hasciicam.1 b/hasciicam/hasciicam.1
index 1d747f8..ff02539 100644
--- a/hasciicam/hasciicam.1
+++ b/hasciicam/hasciicam.1
@@ -75,13 +75,13 @@ Selects a font face to be used in html rendering, it should be fixed size for be
Specifies the refresh interval in seconds between each grabbed frame. Default is \fB2\fP (unuseful when in \fBlive\fP mode).
.B
.IP "-b --aabright"
-Specifies brightness level for the aa_render, from 0 to 100. Default is \fB50\fP.
+Specifies brightness level for the aa_render, from 0 to 100. Default is \fB60\fP.
.B
.IP "-c --aacontrast"
-Specifies contrast level for the aa_render, from 0 to 100. Default is \fB10\fP.
+Specifies contrast level for the aa_render, from 0 to 100. Default is \fB4\fP.
.B
.IP "-g --aagamma"
-Specifies gamma correction level for the aa_render, from 0 to 100. Default is \fB10\fP.
+Specifies gamma correction level for the aa_render, from 0 to 100. Default is \fB3\fP.
.B
.IP "-I --invert"
Invert and render the resulting negative ascii.
@@ -109,7 +109,7 @@ Report bugs to hasciicam@dyne.org. Please include a complete, self-contained exa
.SH AUTHOR
jaromil [aka Denis Roio] <\fIjaromil@dyne.org\fR>
.SH COPYING
-Copyright (c) 2001 jaromil@dyne.org
+Copyright (c) 2001-2006 Denis Roio <jaromil@dyne.org>
.br
Permission is granted to copy, distribute and/or modify this manual under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation. Permission is granted to make and distribute verbatim copies of this manual page provided the above copyright notice and this permission notice are preserved on all copies.
.SH AVAILABILITY
diff --git a/hasciicam/hasciicam.c b/hasciicam/hasciicam.c
index a491e9b..f5a77bd 100644
--- a/hasciicam/hasciicam.c
+++ b/hasciicam/hasciicam.c
@@ -1,5 +1,5 @@
/* HasciiCam 1.0
- * (c) 2000-2003 Denis Rojo aka jaromil
+ * (c) 2000-2006 Denis Rojo aka jaromil
*
* This source code is free software; you can redistribute it and/or
* modify it under the terms of the GNU Public License as published
@@ -16,6 +16,8 @@
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* CONTRIBUTIONS :
+ * Matteo Scassa aka blended <ngul@mammete.it>
+ * wider webcam support
* Diego Torres aka rapid <rapid@ivworlds.org>
* uid/gid handling and some bugfixes
*/
@@ -44,6 +46,8 @@
#include <aalib.h>
#include <ftplib.h>
+
+
/* hasciicam modes */
#define LIVE 0
#define HTML 1
@@ -53,8 +57,8 @@
char *version =
"%s %s - (h)ascii 4 the masses! - http://ascii.dyne.org\n"
- "(c)2000-2003 Denis Rojo < jaromil @ dyne.org >\n"
- "watch out for the (h)ASCII ROOTS http://hascii.org\n\n";
+ "(c)2000-2006 Denis Roio < jaromil @ dyne.org >\n"
+ "watch out for the (h)ASCII ROOTS\n\n";
char *help =
/* "\x1B" "c" <--- SCREEN CLEANING ESCAPE CODE
@@ -79,9 +83,9 @@ char *help =
"-S --font-size html font size (1-4) - default 1\n"
"-a --font-face html font to use - default courier\n"
"-r --refresh refresh delay - default 2\n"
-"-b --aabright ascii brightness - default 50\n"
-"-c --aacontrast ascii contrast - default 10\n"
-"-g --aagamma ascii gamma - default 10\n"
+"-b --aabright ascii brightness - default 60\n"
+"-c --aacontrast ascii contrast - default 4\n"
+"-g --aagamma ascii gamma - default 3\n"
"-I --invert invert colors - default off\n"
"-B --background background color (hex) - default 000000\n"
"-F --foreground foreground color (hex) - default 00FF00\n";
@@ -189,7 +193,7 @@ struct aa_format hascii_format = {
"</PRE>\n</FONT>\n</BODY>\n</HTML>\n",
"\n",
/*The order is:normal, dim, bold, boldfont, reverse, special */
- {"%s", "%s", "%s", "%s", "%s",},
+ {"%s", "%s", "%s", "%s", "%s"},
{"", "", "<B>", "", "<B>"},
{"", "", "</B>", "", "</B>"},
html_escapes
@@ -213,10 +217,22 @@ int palette;
unsigned char *grey;
int YtoRGB[256];
+void YUV420P_to_grey(unsigned char *src, unsigned char *dst, int w, int h) {
+ int c,cc;
+
+ for (c=0,cc=0;c<vid_geo.size;c++,cc+=1)
+ dst[c] = YtoRGB[src[cc]];
+ /*dst=src;*/
+
+}
+
void YUV422_to_grey(unsigned char *src, unsigned char *dst, int w, int h) {
int c,cc;
+
for (c=0,cc=0;c<vid_geo.size;c++,cc+=2)
dst[c] = YtoRGB[src[cc]];
+ /*dst=src;*/
+
}
int vid_detect(char *devfile) {
@@ -244,7 +260,7 @@ int vid_detect(char *devfile) {
res = ioctl(dev,VIDIOCGCAP,&grab_cap);
if(res<0) {
- perror("!! error in VIDIOCGCAP: ");
+ perror("E' QUESTOOO!!!!!! error in VIDIOCGCAP: ");
return -1;
}
@@ -277,6 +293,13 @@ int vid_detect(char *devfile) {
maxw = grab_cap.maxwidth;
maxh = grab_cap.maxheight;
+ /* set default size
+ if default is smaller than minimum size
+ set it to minimum size */
+ if(aa_geo.w <= minw/2) aa_geo.w = minw/2;
+ if(aa_geo.h <= minh/2) aa_geo.h = minh/2;
+
+
if (ioctl (dev, VIDIOCGMBUF, &grab_map) == -1) {
perror("!! error in ioctl VIDIOCGMBUF: ");
return -1;
@@ -320,19 +343,31 @@ int vid_init() {
vid_geo.h = aa_geo.h*2;
vid_geo.w = aa_geo.w*2;
vid_geo.size = vid_geo.w*vid_geo.h;
- palette = VIDEO_PALETTE_YUV422;
+ palette =VIDEO_PALETTE_YUV422;
grey = (unsigned char *) malloc (vid_geo.size);
for (i=0; i< 256; i++)
- YtoRGB[i] = 1.164*(i-16);
+ YtoRGB[i] = 1.164*(i-256); // was(i-16);
+
+ //#############CONTROLL PALETTE##################
+/*VIDEO_PALETTE_RGB24;/*VIDEO_PALETTE_YUV420P;VIDEO_PALETTE_RGB32;/V4L2_PIX_FMT_SBGGR8;V4L2_PIX_FMT_SN9C10X; VIDEO_PALETTE_YUV422;*/
for(i=0; i<grab_map.frames; i++) {
grab_buf[i].format = palette; //RGB24;
grab_buf[i].frame = i;
grab_buf[i].height = vid_geo.h;
grab_buf[i].width = vid_geo.w;
}
-
+
+ if (-1 == ioctl(dev,VIDIOCMCAPTURE,&grab_buf[0])) {
+ palette=VIDEO_PALETTE_YUV420P;
+ for(i=0; i<grab_map.frames; i++) {
+ grab_buf[i].format = palette; //RGB24;
+ }
+ if (-1 == ioctl(dev,VIDIOCMCAPTURE,&grab_buf[0])) {
+ fprintf(stderr,"error in ioctl VIDIOCMCAPTURE: %s",strerror(errno));
+ }
+ }
grab_data = mmap (0, grab_map.size, PROT_READ | PROT_WRITE, MAP_SHARED, dev, 0);
@@ -341,9 +376,10 @@ int vid_init() {
exit (1); }
/* feed up the mmapped frames */
- if (-1 == ioctl(dev,VIDIOCMCAPTURE,&grab_buf[0])) {
- fprintf(stderr,"error in ioctl VIDIOCMCAPTURE: %s",strerror(errno));
- }
+ if (-1 == ioctl(dev,VIDIOCMCAPTURE,&grab_buf[0])) {
+ fprintf(stderr,"error in ioctl VIDIOCMCAPTURE: %s",strerror(errno));
+ }
+
cur_frame = ok_frame = 0;
/* init the html header */
@@ -386,8 +422,11 @@ unsigned char *grab_one () {
return NULL;
}
- YUV422_to_grey(&grab_data[grab_map.offsets[ok_frame]],
- grey,vid_geo.w,vid_geo.h);
+ if(palette == VIDEO_PALETTE_YUV422)
+ YUV422_to_grey(&grab_data[grab_map.offsets[ok_frame]],grey,vid_geo.w,vid_geo.h);
+ else if(palette == VIDEO_PALETTE_YUV420P)
+ YUV420P_to_grey(&grab_data[grab_map.offsets[ok_frame]],grey,vid_geo.w,vid_geo.h);
+
return grey;
@@ -411,11 +450,11 @@ config_init (int argc, char *argv[]) {
strcpy(background,"000000");
strcpy(foreground,"00FF00");
strcpy(fontface,"courier"); /* you'd better choose monospace fonts */
- aa_geo.w = 96;
- aa_geo.h = 72;
- aa_geo.bright = 50;
- aa_geo.contrast = 10;
- aa_geo.gamma = 10;
+ aa_geo.w = 80; // 96;
+ aa_geo.h = 40; // 72;
+ aa_geo.bright = 60;
+ aa_geo.contrast = 4;
+ aa_geo.gamma = 3;
ftp_passive = 0;
@@ -569,12 +608,6 @@ config_init (int argc, char *argv[]) {
}
} while (res > 0);
- /* live mode defaults to a different size */
- if(!whchanged && mode==LIVE) {
- aa_geo.w = 80;
- aa_geo.h = 40;
- }
-
if (useftp) {
/* i have to say i'm quite proud of the parsers i write :) */
char *p, *pp;
@@ -629,7 +662,6 @@ main (int argc, char **argv) {
/* register signal traps */
if (signal (SIGINT, quitproc) == SIG_ERR) {
perror ("Couldn't install SIGINT handler"); exit (1); }
-
fprintf (stderr, version, PACKAGE, VERSION);
/* default values */
@@ -639,18 +671,17 @@ main (int argc, char **argv) {
/* initialize aalib default params */
memcpy (&ascii_hwparms, &aa_defparams, sizeof (struct aa_hardware_params));
ascii_rndparms = aa_getrenderparams();
+
// memcpy (&ascii_rndparms,&aa_defrenderparams,sizeof(struct aa_renderparams));
+ /* set hasciicam options */
+ config_init (argc, argv);
/* gathering aalib commandline options */
aa_parseoptions (&ascii_hwparms, ascii_rndparms, &argc, argv);
-
- /* and hasciicam options */
- config_init (argc, argv);
-
/* detect and init video device */
- if( vid_detect(device) > 0 )
+ if( vid_detect(device) > 0 ) {
vid_init();
- else
+ } else
exit(-1);
/* width/height image setup */
@@ -670,7 +701,7 @@ main (int argc, char **argv) {
case HTML:
ascii_save.name = aafile;
- ascii_save.format = &hascii_format;
+ ascii_save.format = &aa_html_format;
ascii_save.file = NULL;
fprintf (stderr, "using HTML mode dumping to file %s\n", aafile);
@@ -741,20 +772,33 @@ main (int argc, char **argv) {
// ascii_rndparms->inversion = invert;
// ascii_rndparms->randomval = 0;
+
+
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
if (daemon_mode)
daemon (0, 1);
- /* cycle until ctrl-c */
-
- while (userbreak < 1) {
+
+
+
+ while (userbreak <1) {
grab_one ();
-
+
+ int i;
+
+ /*aa_setpalette (gamma di colori, indice, colore rosso, verde, blu)*/
+
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
memcpy (aa_image (ascii_context), grey, vid_geo.size);
aa_render (ascii_context, ascii_rndparms, 0, 0,
vid_geo.w,vid_geo.h);
+
aa_flush (ascii_context);
-
+
+
if (useftp) {
// if (!ftp_connected)
// ftp_connect (ftp_host, ftp_user, ftp_pass, ftp_dir);
@@ -766,8 +810,7 @@ main (int argc, char **argv) {
if(!FtpRename("scolopendro",aafile,ftpconn))
fprintf(stderr,"Error in ftp rename %s\n",FtpLastResponse(ftpconn));
}
-
- if (mode != LIVE) sleep (refresh);
+
}
/* CLEAN EXIT */
@@ -787,6 +830,7 @@ main (int argc, char **argv) {
fprintf (stderr, "cya!\n");
exit (0);
+/*++userbreak;*/
}
/* signal handling */
@@ -799,3 +843,5 @@ quitproc (int Sig)
userbreak = 1;
}
+
+