diff --git a/src/event.cpp b/src/event.cpp index 6e50ea51..d27312fb 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -38,12 +38,9 @@ const char *eventList[] = { "EVENT_TLAPSE_START", "EVENT_TLAPSE_END", "EVENT_STREAM", - "EVENT_IMAGE_DETECTED", - "EVENT_IMAGEM_DETECTED", "EVENT_IMAGE_SNAPSHOT", "EVENT_IMAGE", "EVENT_IMAGEM", - "EVENT_IMAGE_PREVIEW", "EVENT_AREA_DETECTED", "EVENT_CAMERA_LOST", "EVENT_CAMERA_FOUND", @@ -51,15 +48,6 @@ const char *eventList[] = { "EVENT_LAST" }; -static void on_picture_save_command(ctx_dev *cam, char *fname) -{ - MOTPLS_LOG(NTC, TYPE_EVENTS, NO_ERRNO, _("File saved to: %s"), fname); - - if (cam->conf->on_picture_save != "") { - util_exec_command(cam, cam->conf->on_picture_save.c_str(), fname); - } -} - static void on_motion_detected_command(ctx_dev *cam) { if (cam->conf->on_motion_detected != "") { @@ -117,131 +105,7 @@ static void event_vlp_putpipem(ctx_dev *cam) } } -static void event_image_detect(ctx_dev *cam) -{ - char filename[PATH_MAX]; - if (cam->new_img & NEWIMG_ON) { - mypicname(cam, filename,"%s/%s.%s" - , cam->conf->picture_filename - , cam->conf->picture_type); - cam->filetype = FTYPE_IMAGE; - if ((cam->imgs.size_high > 0) && (cam->movie_passthrough == false)) { - cam->picture->save_norm(filename, cam->current_image->image_high); - } else { - cam->picture->save_norm(filename,cam->current_image->image_norm); - } - on_picture_save_command(cam, filename); - dbse_exec(cam, filename, "pic_save"); - } -} - -static void event_imagem_detect(ctx_dev *cam) -{ - char filename[PATH_MAX]; - - if (cam->conf->picture_output_motion == "on") { - mypicname(cam, filename,"%s/%sm.%s" - , cam->conf->picture_filename - , cam->conf->picture_type); - cam->filetype = FTYPE_IMAGE_MOTION; - cam->picture->save_norm(filename, cam->imgs.image_motion.image_norm); - on_picture_save_command(cam, filename); - dbse_exec(cam, filename, "pic_save"); - - } else if (cam->conf->picture_output_motion == "roi") { - mypicname(cam, filename,"%s/%sr.%s" - , cam->conf->picture_filename - , cam->conf->picture_type); - cam->filetype = FTYPE_IMAGE_ROI; - cam->picture->save_roi(filename, cam->current_image->image_norm); - on_picture_save_command(cam, filename); - dbse_exec(cam, filename, "pic_save"); - } -} - -static void event_image_snapshot(ctx_dev *cam) -{ - char filename[PATH_MAX]; - char linkpath[PATH_MAX]; - int offset; - - offset = (int)cam->conf->snapshot_filename.length() - 8; - if (offset < 0) { - offset = 1; - } - - if (cam->conf->snapshot_filename.compare((uint)offset, 8, "lastsnap") != 0) { - mypicname(cam, filename,"%s/%s.%s" - , cam->conf->snapshot_filename - , cam->conf->picture_type); - cam->filetype = FTYPE_IMAGE_SNAPSHOT; - if ((cam->imgs.size_high > 0) && (cam->movie_passthrough == false)) { - cam->picture->save_norm(filename, cam->current_image->image_high); - } else { - cam->picture->save_norm(filename, cam->current_image->image_norm); - } - on_picture_save_command(cam, filename); - dbse_exec(cam, filename, "pic_save"); - - /* Update symbolic link */ - mypicname(cam, linkpath,"%s/%s.%s" - , "lastsnap", cam->conf->picture_type); - remove(linkpath); - if (symlink(filename, linkpath)) { - MOTPLS_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO - ,_("Could not create symbolic link [%s]"), filename); - return; - } - - } else { - mypicname(cam, filename,"%s/%s.%s" - , cam->conf->snapshot_filename - , cam->conf->picture_type); - remove(filename); - cam->filetype = FTYPE_IMAGE_SNAPSHOT; - if ((cam->imgs.size_high > 0) && (cam->movie_passthrough == false)) { - cam->picture->save_norm(filename, cam->current_image->image_high); - } else { - cam->picture->save_norm(filename, cam->current_image->image_norm); - } - on_picture_save_command(cam, filename); - dbse_exec(cam, filename, "pic_save"); - } - - cam->snapshot = 0; -} - -static void event_image_preview(ctx_dev *cam) -{ - char filename[PATH_MAX]; - ctx_image_data *saved_current_image; - - if (cam->imgs.image_preview.diffs) { - saved_current_image = cam->current_image; - saved_current_image->imgts= cam->current_image->imgts; - - cam->current_image = &cam->imgs.image_preview; - cam->current_image->imgts = cam->imgs.image_preview.imgts; - - mypicname(cam, filename,"%s/%s.%s" - , cam->conf->picture_filename - , cam->conf->picture_type); - - cam->filetype = FTYPE_IMAGE; - if ((cam->imgs.size_high > 0) && (cam->movie_passthrough == false)) { - cam->picture->save_norm(filename, cam->imgs.image_preview.image_high); - } else { - cam->picture->save_norm(filename, cam->imgs.image_preview.image_norm); - } - on_picture_save_command(cam, filename); - dbse_exec(cam, filename, "pic_save"); - - /* Restore global context values. */ - cam->current_image = saved_current_image; - cam->current_image->imgts = saved_current_image->imgts; - } -} static void event_camera_lost(ctx_dev *cam) { @@ -336,22 +200,6 @@ struct event_handlers event_handlers[] = { event_movie_end }, { - EVENT_IMAGE_DETECTED, - event_image_detect - }, - { - EVENT_IMAGE_DETECTED, - event_movie_put - }, - { - EVENT_IMAGEM_DETECTED, - event_imagem_detect - }, - { - EVENT_IMAGE_SNAPSHOT, - event_image_snapshot - }, - { EVENT_IMAGE, event_vlp_putpipe }, @@ -360,10 +208,6 @@ struct event_handlers event_handlers[] = { event_vlp_putpipem }, { - EVENT_IMAGE_PREVIEW, - event_image_preview - }, - { EVENT_STREAM, event_stream_put }, diff --git a/src/motion_loop.cpp b/src/motion_loop.cpp index 3fc6bad8..3355bfc3 100644 --- a/src/motion_loop.cpp +++ b/src/motion_loop.cpp @@ -120,6 +120,23 @@ static void mlp_ring_process_debug(ctx_dev *cam) cam->imgs.width, cam->imgs.height, 10, 30, t, cam->text_scale); } +static void mlp_ring_process_image(ctx_dev *cam) +{ + cam->picture->process_norm(); + if (cam->movie_norm->put_image(cam->current_image + , &cam->current_image->imgts) == -1) { + MOTPLS_LOG(ERR, TYPE_EVENTS, NO_ERRNO, _("Error encoding image")); + } + if (cam->movie_motion->put_image(&cam->imgs.image_motion + , &cam->imgs.image_motion.imgts) == -1) { + MOTPLS_LOG(ERR, TYPE_EVENTS, NO_ERRNO, _("Error encoding image")); + } + if (cam->movie_extpipe->put_image(cam->current_image + , &cam->current_image->imgts) == -1) { + MOTPLS_LOG(ERR, TYPE_EVENTS, NO_ERRNO, _("Error encoding image")); + } +} + /* Process the entire image ring */ static void mlp_ring_process(ctx_dev *cam) { @@ -136,8 +153,7 @@ static void mlp_ring_process(ctx_dev *cam) if (cam->motapp->conf->log_level >= DBG) { mlp_ring_process_debug(cam); } - - event(cam, EVENT_IMAGE_DETECTED); + mlp_ring_process_image(cam); } cam->current_image->flags |= IMAGE_SAVED; @@ -258,9 +274,7 @@ static void mlp_detected(ctx_dev *cam) (cam->current_image->shot != 1)) { event(cam, EVENT_STREAM); } - if (conf->picture_output_motion != "off") { - event(cam, EVENT_IMAGEM_DETECTED); - } + cam->picture->process_motion(); } mlp_track_move(cam); @@ -629,7 +643,7 @@ void mlp_cleanup(ctx_dev *cam) if (cam->event_curr_nbr == cam->event_prev_nbr) { mlp_ring_process(cam); if (cam->imgs.image_preview.diffs) { - event(cam, EVENT_IMAGE_PREVIEW); + cam->picture->process_preview(); cam->imgs.image_preview.diffs = 0; } event(cam, EVENT_END); @@ -1144,7 +1158,7 @@ static void mlp_actions_event(ctx_dev *cam) mlp_ring_process(cam); if (cam->imgs.image_preview.diffs) { - event(cam, EVENT_IMAGE_PREVIEW); + cam->picture->process_preview(); cam->imgs.image_preview.diffs = 0; } event(cam, EVENT_END); @@ -1244,7 +1258,7 @@ static void mlp_snapshot(ctx_dev *cam) cam->frame_curr_ts.tv_sec % cam->conf->snapshot_interval <= cam->frame_last_ts.tv_sec % cam->conf->snapshot_interval) || cam->snapshot) { - event(cam, EVENT_IMAGE_SNAPSHOT); + cam->picture->process_snapshot(); cam->snapshot = 0; } } diff --git a/src/picture.cpp b/src/picture.cpp index 710a5990..718da1bc 100644 --- a/src/picture.cpp +++ b/src/picture.cpp @@ -23,8 +23,158 @@ #include "jpegutils.hpp" #include "event.hpp" #include "draw.hpp" +#include "dbse.hpp" #include "picture.hpp" + +void cls_picture::picname(char* fullname, std::string fmtstr + , std::string basename, std::string extname) +{ + char filename[PATH_MAX]; + int retcd; + + mystrftime(cam, filename, sizeof(filename) + , basename.c_str(), NULL); + retcd = snprintf(fullname, PATH_MAX, fmtstr.c_str() + , cfg_target_dir.c_str(), filename, extname.c_str()); + if ((retcd < 0) || (retcd >= PATH_MAX)) { + MOTPLS_LOG(ERR, TYPE_EVENTS, NO_ERRNO + ,_("Error creating picture file name")); + return; + } +} + +void cls_picture::on_picture_save_command(char *fname) +{ + MOTPLS_LOG(NTC, TYPE_EVENTS, NO_ERRNO, _("File saved to: %s"), fname); + + if (cfg_on_picture_save != "") { + util_exec_command(cam, cfg_on_picture_save.c_str(), fname); + } +} + +void cls_picture::process_norm() +{ + char filename[PATH_MAX]; + + if (cam->new_img & NEWIMG_ON) { + picname(filename,"%s/%s.%s" + , cfg_picture_filename + , cfg_picture_type); + cam->filetype = FTYPE_IMAGE; + if ((cam->imgs.size_high > 0) && (cam->movie_passthrough == false)) { + cam->picture->save_norm(filename, cam->current_image->image_high); + } else { + cam->picture->save_norm(filename,cam->current_image->image_norm); + } + on_picture_save_command(filename); + dbse_exec(cam, filename, "pic_save"); + } +} + +void cls_picture::process_motion() +{ + char filename[PATH_MAX]; + + if (cfg_picture_output_motion == "on") { + picname(filename,"%s/%sm.%s", cfg_picture_filename, cfg_picture_type); + cam->filetype = FTYPE_IMAGE_MOTION; + cam->picture->save_norm(filename, cam->imgs.image_motion.image_norm); + on_picture_save_command(filename); + dbse_exec(cam, filename, "pic_save"); + + } else if (cfg_picture_output_motion == "roi") { + picname(filename,"%s/%sr.%s", cfg_picture_filename, cfg_picture_type); + cam->filetype = FTYPE_IMAGE_ROI; + cam->picture->save_roi(filename, cam->current_image->image_norm); + on_picture_save_command(filename); + dbse_exec(cam, filename, "pic_save"); + } +} + +void cls_picture::process_snapshot() +{ + char filename[PATH_MAX]; + char linkpath[PATH_MAX]; + int offset; + + offset = (int)cfg_snapshot_filename.length() - 8; + if (offset < 0) { + offset = 1; + } + + if (cfg_snapshot_filename.compare((uint)offset, 8, "lastsnap") != 0) { + picname(filename,"%s/%s.%s" + , cfg_snapshot_filename + , cfg_picture_type); + cam->filetype = FTYPE_IMAGE_SNAPSHOT; + if ((cam->imgs.size_high > 0) && (cam->movie_passthrough == false)) { + cam->picture->save_norm(filename, cam->current_image->image_high); + } else { + cam->picture->save_norm(filename, cam->current_image->image_norm); + } + on_picture_save_command(filename); + dbse_exec(cam, filename, "pic_save"); + + /* Update symbolic link */ + picname(linkpath,"%s/%s.%s" + , "lastsnap", cfg_picture_type); + remove(linkpath); + if (symlink(filename, linkpath)) { + MOTPLS_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO + ,_("Could not create symbolic link [%s]"), filename); + return; + } + + } else { + picname(filename,"%s/%s.%s" + , cfg_snapshot_filename + , cfg_picture_type); + remove(filename); + cam->filetype = FTYPE_IMAGE_SNAPSHOT; + if ((cam->imgs.size_high > 0) && (cam->movie_passthrough == false)) { + cam->picture->save_norm(filename, cam->current_image->image_high); + } else { + cam->picture->save_norm(filename, cam->current_image->image_norm); + } + on_picture_save_command(filename); + dbse_exec(cam, filename, "pic_save"); + } + + cam->snapshot = 0; +} + +void cls_picture::process_preview() +{ + char filename[PATH_MAX]; + ctx_image_data *saved_current_image; + + if (cam->imgs.image_preview.diffs) { + saved_current_image = cam->current_image; + saved_current_image->imgts= cam->current_image->imgts; + + cam->current_image = &cam->imgs.image_preview; + cam->current_image->imgts = cam->imgs.image_preview.imgts; + + picname(filename,"%s/%s.%s" + , cfg_picture_filename + , cfg_picture_type); + + cam->filetype = FTYPE_IMAGE; + if ((cam->imgs.size_high > 0) && (cam->movie_passthrough == false)) { + cam->picture->save_norm(filename, cam->imgs.image_preview.image_high); + } else { + cam->picture->save_norm(filename, cam->imgs.image_preview.image_norm); + } + on_picture_save_command(filename); + dbse_exec(cam, filename, "pic_save"); + + /* Restore global context values. */ + cam->current_image = saved_current_image; + cam->current_image->imgts = saved_current_image->imgts; + } +} + #ifdef HAVE_WEBP void cls_picture::webp_exif(WebPMux* webp_mux , timespec *ts1, ctx_coord *box) @@ -49,13 +199,14 @@ void cls_picture::webp_exif(WebPMux* webp_mux #endif /* HAVE_WEBP */ /** Save image as webp to file */ -void cls_picture::save_webp(FILE *fp, u_char *image, int width, int height, - int quality, timespec *ts1, ctx_coord *box) +void cls_picture::save_webp(FILE *fp, u_char *image, int width, int height + , timespec *ts1, ctx_coord *box) { #ifdef HAVE_WEBP /* Create a config present and check for compatible library version */ WebPConfig webp_config; - if (!WebPConfigPreset(&webp_config, WEBP_PRESET_DEFAULT, (float) quality)) { + if (!WebPConfigPreset(&webp_config, WEBP_PRESET_DEFAULT + , (float) cfg_picture_quality)) { MOTPLS_LOG(ERR, TYPE_CORE, NO_ERRNO, _("libwebp version error")); return; } @@ -130,15 +281,14 @@ void cls_picture::save_webp(FILE *fp, u_char *image, int width, int height, (void)image; (void)width; (void)height; - (void) quality; (void)ts1; (void)box; #endif /* HAVE_WEBP */ } /** Save image as yuv420p jpeg to file */ -void cls_picture::save_yuv420p(FILE *fp, u_char *image, int width, int height, - int quality, timespec *ts1, ctx_coord *box) +void cls_picture::save_yuv420p(FILE *fp, u_char *image, int width, int height + , timespec *ts1, ctx_coord *box) { int sz, image_size; @@ -146,7 +296,8 @@ void cls_picture::save_yuv420p(FILE *fp, u_char *image, int width, int height, image_size = (width * height * 3)/2; u_char *buf =(u_char*) mymalloc(image_size); - sz = jpgutl_put_yuv420p(buf, image_size, image, width, height, quality, cam ,ts1, box); + sz = jpgutl_put_yuv420p(buf, image_size, image, width, height + , cfg_picture_quality, cam ,ts1, box); fwrite(buf, (uint)sz, 1, fp); free(buf); @@ -154,8 +305,8 @@ void cls_picture::save_yuv420p(FILE *fp, u_char *image, int width, int height, } /** Save image as grey jpeg to file */ -void cls_picture::save_grey(FILE *picture, u_char *image, int width, int height, - int quality, timespec *ts1, ctx_coord *box) +void cls_picture::save_grey(FILE *picture, u_char *image, int width, int height + , timespec *ts1, ctx_coord *box) { int sz, image_size; @@ -163,7 +314,8 @@ void cls_picture::save_grey(FILE *picture, u_char *image, int width, int height, u_char *buf =(u_char*) mymalloc(image_size); - sz = jpgutl_put_grey(buf, image_size, image, width, height, quality, cam ,ts1, box); + sz = jpgutl_put_grey(buf, image_size, image, width, height + , cfg_picture_quality, cam ,ts1, box); fwrite(buf, (uint)sz, 1, picture); free(buf); @@ -239,21 +391,22 @@ int cls_picture::put_memory(u_char *img_dst, int image_size , u_char *image, int quality, int width, int height) { struct timespec ts1; + int retcd; clock_gettime(CLOCK_REALTIME, &ts1); - if (stream_grey) { - return jpgutl_put_grey(img_dst, image_size, image, - width, height, quality, cam,&ts1, NULL); + if (cfg_stream_grey) { + retcd = jpgutl_put_grey(img_dst, image_size, image + , width, height, quality, cam, &ts1, NULL); } else { - return jpgutl_put_yuv420p(img_dst, image_size, image, - width, height, quality, cam ,&ts1, NULL); + retcd = jpgutl_put_yuv420p(img_dst, image_size, image + , width, height, quality, cam, &ts1, NULL); } - return 0; + return retcd; } /* Write the picture to a file */ -void cls_picture::pic_write(FILE *picture, u_char *image, int quality) +void cls_picture::pic_write(FILE *picture, u_char *image) { int width, height; @@ -266,16 +419,16 @@ void cls_picture::pic_write(FILE *picture, u_char *image, int quality) height = cam->imgs.height; } - if (picture_type == "ppm") { + if (cfg_picture_type == "ppm") { save_ppm(picture, image, width, height); - } else if (picture_type == "webp") { - save_webp(picture, image, width, height, quality + } else if (cfg_picture_type == "webp") { + save_webp(picture, image, width, height , &(cam->current_image->imgts), &(cam->current_image->location)); - } else if (picture_type == "grey") { - save_grey(picture, image, width, height, quality + } else if (cfg_picture_type == "grey") { + save_grey(picture, image, width, height , &(cam->current_image->imgts), &(cam->current_image->location)); } else { - save_yuv420p(picture, image, width, height, quality + save_yuv420p(picture, image, width, height , &(cam->current_image->imgts), &(cam->current_image->location)); } } @@ -303,7 +456,7 @@ void cls_picture::save_norm(char *file, u_char *image) } } - pic_write(picture, image, picture_quality); + pic_write(picture, image); myfclose(picture); } @@ -342,7 +495,7 @@ void cls_picture::save_roi(char *file, u_char *image) sz = jpgutl_put_grey(buf, image_size, img , bx->width, bx->height - , picture_quality, cam + , cfg_picture_quality, cam ,&(cam->current_image->imgts), bx); fwrite(buf, (uint)sz, 1, picture); @@ -479,7 +632,7 @@ void cls_picture::write_mask(const char *file) MOTPLS_LOG(ERR, TYPE_ALL, NO_ERRNO ,_("Creating empty mask %s\nPlease edit this file and " - "re-run motion to enable mask feature"), mask_file.c_str()); + "re-run motion to enable mask feature"), cfg_mask_file.c_str()); } void cls_picture::scale_img(int width_src, int height_src, u_char *img_src, u_char *img_dst) @@ -553,8 +706,8 @@ void cls_picture::init_privacy() cam->imgs.mask_privacy_high = NULL; cam->imgs.mask_privacy_high_uv = NULL; - if (mask_privacy != "") { - if ((picture = myfopen(mask_privacy.c_str(), "rbe"))) { + if (cfg_mask_privacy != "") { + if ((picture = myfopen(cfg_mask_privacy.c_str(), "rbe"))) { MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO, _("Opening privacy mask file")); /* * NOTE: The mask is expected to have the output dimensions. I.e., the mask @@ -576,9 +729,9 @@ void cls_picture::init_privacy() myfclose(picture); } else { MOTPLS_LOG(ERR, TYPE_ALL, SHOW_ERRNO - ,_("Error opening mask file %s"), mask_privacy.c_str()); + ,_("Error opening mask file %s"), cfg_mask_privacy.c_str()); /* Try to write an empty mask file to make it easier for the user to edit it */ - write_mask(mask_privacy.c_str() ); + write_mask(cfg_mask_privacy.c_str() ); } if (!cam->imgs.mask_privacy) { @@ -586,7 +739,7 @@ void cls_picture::init_privacy() ,_("Failed to read mask privacy image. Mask privacy feature disabled.")); } else { MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO - ,_("Mask privacy file \"%s\" loaded."), mask_privacy.c_str()); + ,_("Mask privacy file \"%s\" loaded."), cfg_mask_privacy.c_str()); indx_img = 1; if (cam->imgs.size_high > 0) { @@ -649,8 +802,8 @@ void cls_picture::init_mask() FILE *picture; /* Load the mask file if any */ - if (mask_file != "") { - if ((picture = myfopen(mask_file.c_str(), "rbe"))) { + if (cfg_mask_file != "") { + if ((picture = myfopen(cfg_mask_file.c_str(), "rbe"))) { /* * NOTE: The mask is expected to have the output dimensions. I.e., the mask * applies to the already rotated image, not the capture image. Thus, use @@ -661,12 +814,12 @@ void cls_picture::init_mask() } else { MOTPLS_LOG(ERR, TYPE_ALL, SHOW_ERRNO ,_("Error opening mask file %s") - ,mask_file.c_str()); + ,cfg_mask_file.c_str()); /* * Try to write an empty mask file to make it easier * for the user to edit it */ - write_mask(mask_file.c_str()); + write_mask(cfg_mask_file.c_str()); } if (!cam->imgs.mask) { @@ -675,24 +828,34 @@ void cls_picture::init_mask() } else { MOTPLS_LOG(INF, TYPE_ALL, NO_ERRNO ,_("Maskfile \"%s\" loaded.") - ,mask_file.c_str()); + ,cfg_mask_file.c_str()); } } else { cam->imgs.mask = NULL; } } +void cls_picture::init_cfg() +{ + /* Isolate config params from webcontrol changes*/ + cfg_stream_grey = cam->conf->stream_grey; + cfg_picture_type = cam->conf->picture_type; + cfg_mask_file = cam->conf->mask_file; + cfg_mask_privacy = cam->conf->mask_privacy; + cfg_w = cam->conf->width; + cfg_h = cam->conf->height; + cfg_picture_quality = cam->conf->picture_quality; + cfg_on_picture_save = cam->conf->on_picture_save; + cfg_target_dir = cam->conf->target_dir; + cfg_picture_filename = cam->conf->picture_filename; + cfg_snapshot_filename = cam->conf->snapshot_filename; + cfg_picture_output_motion = cam->conf->picture_output_motion; +} + cls_picture::cls_picture(ctx_dev *p_cam) { cam = p_cam; - stream_grey = cam->conf->stream_grey; - picture_type = cam->conf->picture_type; - mask_file = cam->conf->mask_file; - mask_privacy = cam->conf->mask_privacy; - cfg_w = cam->conf->width; - cfg_h = cam->conf->height; - picture_quality = cam->conf->picture_quality; - + init_cfg(); init_mask(); init_privacy(); diff --git a/src/picture.hpp b/src/picture.hpp index faa10f21..fd8715d7 100644 --- a/src/picture.hpp +++ b/src/picture.hpp @@ -29,45 +29,56 @@ class cls_picture { cls_picture(ctx_dev *p_cam); ~cls_picture(); - int put_memory(u_char* img_dst , int image_size, u_char *image, int quality, int width, int height); - void save_norm( char *file, u_char *image); - void save_roi( char *file, u_char *image); - u_char *load_pgm(FILE *picture, int width, int height); void scale_img(int width_src, int height_src, u_char *img_src, u_char *img_dst); void save_preview(); + void process_norm(); + void process_motion(); + void process_snapshot(); + void process_preview(); private: ctx_dev *cam; - bool stream_grey; - std::string picture_type; - std::string mask_file; - std::string mask_privacy; int cfg_w; int cfg_h; - int picture_quality; - + int cfg_picture_quality; + bool cfg_stream_grey; + std::string cfg_mask_file; + std::string cfg_mask_privacy; + std::string cfg_on_picture_save; + std::string cfg_target_dir; + std::string cfg_picture_filename; + std::string cfg_picture_type; + std::string cfg_snapshot_filename; + std::string cfg_picture_output_motion; #ifdef HAVE_WEBP void webp_exif(WebPMux* webp_mux , timespec *ts1, ctx_coord *box); #endif void save_webp(FILE *fp, u_char *image - , int width, int height, int quality + , int width, int height , timespec *ts1, ctx_coord *box); void save_yuv420p(FILE *fp, u_char *image - , int width, int height, int quality + , int width, int height , timespec *ts1, ctx_coord *box); void save_grey(FILE *picture, u_char *image - , int width, int height, int quality + , int width, int height , timespec *ts1, ctx_coord *box); + void save_norm( char *file, u_char *image); + void save_roi( char *file, u_char *image); void save_ppm(FILE *picture, u_char *image, int width, int height); - void pic_write(FILE *picture, u_char *image, int quality); + void pic_write(FILE *picture, u_char *image); + u_char *load_pgm(FILE *picture, int width, int height); void write_mask(const char *file); void init_privacy(); void init_mask(); + void init_cfg(); + void on_picture_save_command(char *fname); + void picname(char* fullname, std::string fmtstr + , std::string basename, std::string extname); }; diff --git a/src/util.cpp b/src/util.cpp index 332ffdc3..273cd98a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -608,24 +608,6 @@ size_t mystrftime(ctx_dev *cam, char *s, size_t max return strftime(s, max, format, ×tamp_tm); } -void mypicname(ctx_dev *cam - , char* fullname, std::string fmtstr - , std::string basename, std::string extname) -{ - char filename[PATH_MAX]; - int retcd; - - mystrftime(cam, filename, sizeof(filename) - , basename.c_str(), NULL); - retcd = snprintf(fullname, PATH_MAX, fmtstr.c_str() - , cam->conf->target_dir.c_str(), filename, extname.c_str()); - if ((retcd < 0) || (retcd >= PATH_MAX)) { - MOTPLS_LOG(ERR, TYPE_EVENTS, NO_ERRNO - ,_("Error creating picture file name")); - return; - } -} - void mythreadname_set(const char *abbr, int threadnbr, const char *threadname) { /* When the abbreviation is sent in as null, that means we are being