Skip to content

Commit

Permalink
tweaks on the pi
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias-Wandel committed Nov 22, 2018
1 parent 35e097b commit 9531a65
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 33 deletions.
5 changes: 3 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ all: objdir imgcomp blink_camera_led
objdir:
@mkdir -p obj

objs = $(OBJ)/main.o $(OBJ)/compare.o $(OBJ)/jpeg2mem.o \
objs = $(OBJ)/main.o $(OBJ)/config.o $(OBJ)/compare.o $(OBJ)/jpeg2mem.o \
$(OBJ)/jpgfile.o $(OBJ)/exif.o $(OBJ)/start_raspistill.o $(OBJ)/util.o

$(OBJ)/jpgfile.o $(OBJ)/exif.o $(OBJ)/start_raspistill.o: $(SRC)/jhead.h
$(OBJ)/main.o $(OBJ)/config.o: $(SRC)/config.h

$(OBJ)/%.o:$(SRC)/%.c $(SRC)/imgcomp.h
${CC} $(CFLAGS) -c $< -o $@
Expand All @@ -26,7 +27,7 @@ $(SRC)/pi_model.h:
$(SRC)/identify_pi >> $(SRC)/pi_model.h

blink_camera_led: $(SRC)/blink_camera_led.c $(SRC)/pi_model.h
$(CC) -o blink_camera_led $(SRC)/blink_camera_led.c
$(CC) -o blink_camera_led $(SRC)/blink_camera_led.c

libjpeg/libjpeg.a:
cd libjpeg; make
Expand Down
50 changes: 27 additions & 23 deletions src/config.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,33 @@ void usage (void)// complain about bad command line
fprintf(stderr, "usage: %s [switches] ", progname);
fprintf(stderr, "inputfile outputfile\n");

fprintf(stderr, "Switches (names may be abbreviated):\n");
fprintf(stderr, " -scale N Scale before detection by 1/N. Default 1/4\n");
fprintf(stderr, " -region x1-x2,y1-y2 Specify region of interest\n");
fprintf(stderr, " -exclude x1-x2,y1-y2 Exclude from area of interest\n");
fprintf(stderr, " -diffmap <filename> A file to use as diff map\n");
fprintf(stderr, " -dodir <srcdir> Compare images in dir, in order\n");
fprintf(stderr, " -followdir <srcdir> Do dir and monitor for new images\n");
fprintf(stderr, " -savedir <saveto> Where to save images with changes\n");
fprintf(stderr, " -savenames <scheme> Output naming scheme. Uses strftime\n"
" to format the output name. May include\n"
" '/' characters for directories.\n");
fprintf(stderr, " -sensitivity N Set sensitivity. Lower=more sensitive\n");
fprintf(stderr, " -blink_cmd <command> Run this command when motion detected\n"
" (used to blink the camera LED)\n");
fprintf(stderr, " -tl N Save image every N seconds regardless\n");
fprintf(stderr, " -spurious Ignore any change that returns to\n"
" previous image in the next frame\n");
fprintf(stderr, " -sendsigs Send signal to raspistil every second\n");
fprintf(stderr, " For continous AE rapsistill, default off\n");
fprintf(stderr, " -brmonitor Restart raspistill on brightness\n");
fprintf(stderr, " changes (default on)\n");
fprintf(stderr, " -verbose or -debug Emit more verbose output\n");

fprintf(stderr,
"Switches (names may be abbreviated):\n"
" -scale N Scale before detection by 1/N. Default 1/4\n"
" -region x1-x2,y1-y2 Specify region of interest\n"
" -exclude x1-x2,y1-y2 Exclude from area of interest\n"
" -diffmap <filename> A file to use as diff map\n"
" -dodir <srcdir> Compare images in dir, in order\n"
" -followdir <srcdir> Do dir and monitor for new images\n"
" -savedir <saveto> Where to save images with changes\n"
" -savenames <scheme> Output naming scheme. Uses strftime\n"
" to format the output name. May include\n"
" '/' characters for directories.\n"
" -sensitivity N Set sensitivity. Lower=more sensitive\n"
" -blink_cmd <command> Run this command when motion detected\n"
" (used to blink the camera LED)\n"
" -tl N Save image every N seconds regardless\n"
" -spurious Ignore any change that returns to\n"
" previous image in the next frame\n"
" -sendsigs Send signal to raspistil every second\n"
" For continous AE rapsistill, default off\n"
" -brmonitor Restart raspistill on brightness\n"
" changes (default on)\n"
" -verbose or -debug Emit more verbose output\n"
" -logtofile Log to file instead of stdout\n"
" -movelognames <schme> Rotate log files, scheme works just like\n"
" it does for savenames\n");

exit(-1);
}

Expand Down
3 changes: 2 additions & 1 deletion src/exif.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ typedef struct {

//--------------------------------------------------------------------------
// Table of Jpeg encoding process names
/*
static const TagTable_t ProcessTable[] = {
{ M_SOF0, "Baseline"},
{ M_SOF1, "Extended sequential"},
Expand All @@ -37,7 +38,7 @@ static const TagTable_t ProcessTable[] = {
{ M_SOF14, "Differential progressive, arithmetic coding"},
{ M_SOF15, "Differential lossless, arithmetic coding"},
};

*/
#define PROCESS_TABLE_SIZE (sizeof(ProcessTable) / sizeof(TagTable_t))

// 1 - "The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side."
Expand Down
9 changes: 4 additions & 5 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ static int ProcessImage(LastPic_t * New)
fprintf(Log,"Mouse left box!\n");
SinceMotionFrames = 0; // Just to be on the safe side.
}
if (SinceMotionFrames == 5){ // adjust
if (SinceMotionFrames == 50){ // adjust
if (SawMouse){
SawMouse = 0;
fprintf(Log,"Move the gate\n");
Expand All @@ -189,7 +189,7 @@ static int ProcessImage(LastPic_t * New)
if (LastPics[2].Image != NULL){
// Third picture now falls out of the window. Free it and delete it.

if (SinceMotionFrames > 5){ // adjust
if (SinceMotionFrames > 200){ // adjust
// If it's been 200 images ince we saw motion, save this image
// as a background image for later mouse detection.
//printf("Save image as background");
Expand Down Expand Up @@ -245,7 +245,7 @@ static int DoDirectoryFunc(char * Directory)
//printf("sorted dir: %s\n",FileNames[a]);
NewPic.Image = LoadJPEG(NewPic.Name, ScaleDenom, 0, ReadExif);
if (NewPic.Image == NULL){
fprintf(stderr, "Failed to load %s\n",NewPic.Name);
fprintf(Log, "Failed to load %s\n",NewPic.Name);
if (FollowDir){
// Raspberry pi timelapse mode may at times dump a corrupt
// picture at the end of timelapse mode. Just delete and go on.
Expand Down Expand Up @@ -297,7 +297,6 @@ int DoDirectory(char * Directory)
break;
}
}
// if (LastPic != NULL) free(LastPic);
return a;
}

Expand All @@ -319,7 +318,7 @@ int main(int argc, char **argv)

Log = stdout;

printf("Imgcomp version 0.8 (January 2016) by Matthias Wandel\n\n");
printf("Imgcomp version 0.9 (Nov 2018) by Matthias Wandel\n\n");

progname = argv[0];

Expand Down
9 changes: 7 additions & 2 deletions src/util.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,10 @@ void LogFileMaintain()
}
if (MoveLogNames[0]){
strftime(NewLogTo, PATH_MAX, MoveLogNames, localtime(&LastPic_mtime));
printf("log name: %s\n",NewLogTo);
//printf("log name: %s\n",NewLogTo);
if (strcmp(ThisLogTo, NewLogTo)){
if (Log != NULL){
printf("Log rotate %s --> %s\n", ThisLogTo, NewLogTo);
fprintf(Log,"Log rotate %s --> %s\n", ThisLogTo, NewLogTo);
fclose(Log);
Log = NULL;
EnsurePathExists(NewLogTo);
Expand All @@ -364,10 +364,15 @@ void LogFileMaintain()

if (Log == NULL){
Log = fopen(LogToFile,"w");
if (Log == NULL){
fprintf(stderr, "Failed to open log file %s\n",LogToFile);
}
if (ThisLogTo[0]){
strncpy(ThisLogTo, NewLogTo, PATH_MAX);
}
return;
}else{
fflush(Log); // Do log to ram disk, or this wears out flash!
}
}

Expand Down

0 comments on commit 9531a65

Please sign in to comment.