camServer.c File Reference

Streams a raw video stream over TCP. More...

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <linux/videodev.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <strings.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <signal.h>
#include <time.h>
#include <libfg/capture.h>
#include "frameconversions.h"
#include "blob.h"
#include "kh3moves.h"

Include dependency graph for camServer.c:

Go to the source code of this file.

Defines

#define DEFAULT_PORT   3000
 Default TCP port we listen on.
#define CAMERAANGLE   34
 Camera opening angle.
#define ROTATIONSTRESH   5
 Object position changes below this do not trigger the rotation.
#define FG_WIDTH   176
 Default frame width.
#define FG_HEIGHT   144
 Default frame height.
#define FG_BRIGHTNESS   66
 Default picture brightness.
#define FG_CONTRAST   15
 Default picture contrast.
#define FG_PALETTE   VIDEO_PALETTE_RGB32
 Default color depth - look into videodev.h for reference.

Functions

void handle_kill (int signal)
 Handles system signals, for example Ctrl-C.
void showHelp ()
 Show a small help for users convinience.
int parseOptions (int argc, char *argv[])
 Parse options we got on the command line.
void followBlob (blob_t *blob, const shsv_frame_t *frame)
 Computes a rotation angle needed to center the given blob in the picture and rotate the robot.
int main (int argc, char *argv[])
 Main program.

Variables

char * videoDeviceName = "/dev/v4l/video0"
 Default video device we read from.
int servSock = -1
 Server socket which listens to connections.
int servPort = DEFAULT_PORT
 The TCP we listen on.
int client = -1
 Actual connection to a client.
char doFollowBlob = 0
 Indicates if we shoud activly follow the blob or just track it without movement.
char doSendVideo = 1
 Tells if we really should send the video stream.
char doDrawBlobs = 1
 Tells, if to draw fancy borders around the blobs.
FRAMEGRABBER * fg = NULL
 Frame grabber which hides the whole V4L thing.
FRAME * frame = NULL
 The frame we get from the frame grabber.
bgr_frame_tbgrFrame = NULL
 Our BGR frame.
shsv_frame_tshsvFrame = NULL
 Our HSV frame.
int optind
 External variable for command line option parsing.
int optopt
 External variable for command line option parsing.
char * optarg
 External variable for command line option parsing.
int hueMin = -1
 Blob HSV treshhold value for blob tracking.
int hueMax = -1
 Blob HSV treshhold value for blob tracking.
int satMin = -1
 Blob HSV treshhold value for blob tracking.
int satMax = -1
 Blob HSV treshhold value for blob tracking.
int valMin = -1
 Blob HSV treshhold value for blob tracking.
int valMax = -1
 Blob HSV treshhold value for blob tracking.


Detailed Description

Streams a raw video stream over TCP.

Of course UDP would be more convinient for video streaming, but dealing with package loss would cost too much work. Many thanks to Ibraguim Kouliev for his tips and tricks concerning image processing in general and particular in C/C++ Original idea from by Jean-Pierre Laurent <laurent@info.unicaen.fr> rewritten for the usage of libfg by Adalbert Prokop <prokop@informatik.uni-bonn.de>

Version:
Id
camServer.c,v 1.14 2008/09/18 12:59:01 prokop Exp

Definition in file camServer.c.


Define Documentation

#define CAMERAANGLE   34

Camera opening angle.

Definition at line 76 of file camServer.c.

#define DEFAULT_PORT   3000

Default TCP port we listen on.

Definition at line 73 of file camServer.c.

#define FG_BRIGHTNESS   66

Default picture brightness.

[0..100]

Definition at line 63 of file camServer.c.

#define FG_CONTRAST   15

Default picture contrast.

[0..100]

Definition at line 65 of file camServer.c.

#define FG_HEIGHT   144

Default frame height.

Definition at line 61 of file camServer.c.

#define FG_PALETTE   VIDEO_PALETTE_RGB32

Default color depth - look into videodev.h for reference.

Definition at line 68 of file camServer.c.

#define FG_WIDTH   176

Default frame width.

Definition at line 59 of file camServer.c.

#define ROTATIONSTRESH   5

Object position changes below this do not trigger the rotation.

Definition at line 78 of file camServer.c.


Function Documentation

void followBlob ( blob_t blob,
const shsv_frame_t frame 
)

Computes a rotation angle needed to center the given blob in the picture and rotate the robot.

Parameters:
blob The blob we will center in the picture
frame the picture frame in which we want to center the blob. We need it, because it holds the information about its width.

Definition at line 304 of file camServer.c.

void handle_kill ( int  signal  ) 

Handles system signals, for example Ctrl-C.

Right now it closes all connections and exits

Parameters:
signal Signal we receive

Definition at line 147 of file camServer.c.

int main ( int  argc,
char *  argv[] 
)

Main program.

Parameters:
argc Argument count
argv Argument vector

Definition at line 328 of file camServer.c.

int parseOptions ( int  argc,
char *  argv[] 
)

Parse options we got on the command line.

This will also set some global variables.

Parameters:
argc number of command line options
argv options vector
Returns:
Index of the first non-option argument

Definition at line 196 of file camServer.c.

void showHelp ( void   ) 

Show a small help for users convinience.

Definition at line 171 of file camServer.c.


Variable Documentation

Our BGR frame.

Definition at line 94 of file camServer.c.

int client = -1

Actual connection to a client.

Definition at line 108 of file camServer.c.

char doDrawBlobs = 1

Tells, if to draw fancy borders around the blobs.

Definition at line 141 of file camServer.c.

char doFollowBlob = 0

Indicates if we shoud activly follow the blob or just track it without movement.

Definition at line 132 of file camServer.c.

char doSendVideo = 1

Tells if we really should send the video stream.

This is kind of a hack because the blob tracker work only if an active connection is present, but in this case no picture is transmitted through the connection.

Definition at line 138 of file camServer.c.

FRAMEGRABBER* fg = NULL

Frame grabber which hides the whole V4L thing.

Definition at line 90 of file camServer.c.

FRAME* frame = NULL

The frame we get from the frame grabber.

Definition at line 92 of file camServer.c.

int hueMax = -1

Blob HSV treshhold value for blob tracking.

It will be set from command line value.

Definition at line 122 of file camServer.c.

int hueMin = -1

Blob HSV treshhold value for blob tracking.

It will be set from command line value.

Definition at line 121 of file camServer.c.

char* optarg

External variable for command line option parsing.

int optind

External variable for command line option parsing.

int optopt

External variable for command line option parsing.

int satMax = -1

Blob HSV treshhold value for blob tracking.

It will be set from command line value.

Definition at line 124 of file camServer.c.

int satMin = -1

Blob HSV treshhold value for blob tracking.

It will be set from command line value.

Definition at line 123 of file camServer.c.

int servPort = DEFAULT_PORT

The TCP we listen on.

Can be changed by the user.

Definition at line 105 of file camServer.c.

int servSock = -1

Server socket which listens to connections.

Definition at line 103 of file camServer.c.

Our HSV frame.

Definition at line 96 of file camServer.c.

int valMax = -1

Blob HSV treshhold value for blob tracking.

It will be set from command line value.

Definition at line 126 of file camServer.c.

int valMin = -1

Blob HSV treshhold value for blob tracking.

It will be set from command line value.

Definition at line 125 of file camServer.c.

char* videoDeviceName = "/dev/v4l/video0"

Default video device we read from.

Definition at line 100 of file camServer.c.


Generated on Sun Sep 28 21:20:01 2008 for Guard by  doxygen 1.5.6