Send Motion-user mailing list submissions to motion-user@lists.sourceforge.net
To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/motion-user or, via email, send a message with subject or body 'help' to motion-user-requ...@lists.sourceforge.net You can reach the person managing the list at motion-user-ow...@lists.sourceforge.net When replying, please edit your Subject line so it is more specific than "Re: Contents of Motion-user digest..." Today's Topics: 1. Motion in low light (Rusty Lemur) 2. Re: Motion in low light (tosiara) 3. Slow privacy mask loops? (Pascal F. Martin) 4. Re: Slow privacy mask loops? (MrDave) ---------------------------------------------------------------------- Message: 1 Date: Tue, 28 Feb 2017 22:33:59 -0600 From: Rusty Lemur <rusty.le...@gmail.com> Subject: [Motion-user] Motion in low light To: Motion discussion list <motion-user@lists.sourceforge.net> Message-ID: <CAFzrdHuqMK+M6C+n4tR=0whuktkur-b5oc9gwsjpg-am48p...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hello experts, Is it possible to improve performance in low-light scenarios over the default configurations? I have motion running with a simple USB webcam, but when the room it's in gets dim, there is just darkness displayed. I'm not expecting to be able to see in the dark with it, but are there settings I can use to squeeze as much low-light detail as possible? Thanks, Rusty -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ Message: 2 Date: Wed, 1 Mar 2017 21:33:17 +0200 From: tosiara <tosi...@gmail.com> Subject: Re: [Motion-user] Motion in low light To: Motion discussion list <motion-user@lists.sourceforge.net> Message-ID: <cachtdwrcywz_nrwnu3ns1wz772usxr_yqgvu9vdi-oyb6r3...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 If your camera allows, remove IR filter from lens - this will improve a little. Want more? Get IR LED light and you will see in the dark On Wed, Mar 1, 2017 at 6:33 AM, Rusty Lemur <rusty.le...@gmail.com> wrote: > Hello experts, > > Is it possible to improve performance in low-light scenarios over the > default configurations? I have motion running with a simple USB webcam, but > when the room it's in gets dim, there is just darkness displayed. I'm not > expecting to be able to see in the dark with it, but are there settings I > can use to squeeze as much low-light detail as possible? > > Thanks, > Rusty > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > _______________________________________________ > Motion-user mailing list > Motion-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/motion-user > https://motion-project.github.io/ > > Unsubscribe: https://lists.sourceforge.net/lists/options/motion-user ------------------------------ Message: 3 Date: Sun, 5 Mar 2017 20:37:34 -0800 From: "Pascal F. Martin" <pascal.fb.mar...@gmail.com> Subject: [Motion-user] Slow privacy mask loops? To: motion-user@lists.sourceforge.net Message-ID: <dc552463-ade6-ed0b-6c8a-e3e0c4c53...@gmail.com> Content-Type: text/plain; charset="utf-8" While searching for something else, I found that function mlp_mask_privacy (in file motion.c) executes a slow double loop with a lot of invariant re-calculation in the inner loop: for (indxrow = 0; indxrow < cnt->imgs.height; indxrow++) { for (indxcol = 0; indxcol < cnt->imgs.width; indxcol++) { cnt->current_image->image[indxcol + (indxrow*cnt->imgs.width)] |= cnt->imgs.mask_privacy[indxcol + (indxrow*cnt->imgs.width)]; } } The operations are for "unsigned char". The current_image and mask_privacy have the same layout: a flat array of bytes. A single loop would do at a lower cost. What tickled me was the code comment: "This is done strictly for processing efficiency to lower cpu". Oh, well.. The following code is equivalent, but more efficient: int index = cnt->imgs.height*cnt->imgs.width; unsigned char *image = cnt->current_image->image; const unsigned char *mask = cnt->imgs.mask_privacy; while (index > sizeof(unsigned long)) { *((unsigned long *)image) |= *((unsigned long *)mask); image += sizeof(unsigned long); mask += sizeof(unsigned long); index -= sizeof(unsigned long); } while (--index >= 0) {// process the last few remaining bytes, if any. *(image++) |= *(mask++); } The relative results (with or without gcc optimizations) are below: $ cc imagespeed.c -o imagespeed $ ./imagespeed 10000 Testing privacy mask loop (repeat 10000 times) Execution time (original loop): 25 sec. Execution time (improved loop): 3 sec. $ cc -O2 imagespeed.c -o imagespeed $ ./imagespeed 100000 Testing privacy mask loop (repeat 100000 times) Execution time (original loop): 64 sec. Execution time (improved loop): 4 sec. Doing a flat loop with minimal calculations about double the speed. Preceding it with the "unsigned long" loop multiply the speed by an additional factor of 8 on my 64 bit PC. To my surprise, the gain is much lower (but still dramatic) when compiled without optimization. I attached the source file of my performance test. It simulates the same struct indirections as used by motion.c and starts by generating a binary pattern for the current image and another for the mask, calculates the masked image using each method and compare the binary result. If the check passed, it runs the performance tests. That is the full extend of my testing thus far. Comments are welcome. I have prepared a modified version of motion.c, but I still have to test it. Thanks. Pascal. -------------- next part -------------- An HTML attachment was scrubbed... -------------- next part -------------- A non-text attachment was scrubbed... Name: imagespeed.c Type: text/x-csrc Size: 2895 bytes Desc: not available ------------------------------ Message: 4 Date: Sun, 5 Mar 2017 22:05:22 -0700 From: MrDave <motionmrd...@gmail.com> Subject: Re: [Motion-user] Slow privacy mask loops? To: motion-user@lists.sourceforge.net Message-ID: <a39d83ff-6af9-df9f-7be9-0d00d5a00...@gmail.com> Content-Type: text/plain; charset="windows-1252" I have set up a new issue on github for this. On 3/5/2017 9:37 PM, Pascal F. Martin wrote: > > While searching for something else, I found that function > mlp_mask_privacy (in file motion.c) executes a slow double loop with a > lot of invariant re-calculation in the inner loop: > > for (indxrow = 0; indxrow < cnt->imgs.height; indxrow++) { > for (indxcol = 0; indxcol < cnt->imgs.width; indxcol++) { > cnt->current_image->image[indxcol + > (indxrow*cnt->imgs.width)] |= cnt->imgs.mask_privacy[indxcol + > (indxrow*cnt->imgs.width)]; > } > } > > The operations are for "unsigned char". The current_image and > mask_privacy have the same layout: a flat array of bytes. A single > loop would do at a lower cost. What tickled me was the code comment: > "This is done strictly for processing efficiency to lower cpu". Oh, well.. > > The following code is equivalent, but more efficient: > > int index = cnt->imgs.height*cnt->imgs.width; > unsigned char *image = cnt->current_image->image; > const unsigned char *mask = cnt->imgs.mask_privacy; > > while (index > sizeof(unsigned long)) { > *((unsigned long *)image) |= *((unsigned long *)mask); > image += sizeof(unsigned long); > mask += sizeof(unsigned long); > index -= sizeof(unsigned long); > } > while (--index >= 0) {// process the last few remaining bytes, > if any. > *(image++) |= *(mask++); > } > > The relative results (with or without gcc optimizations) are below: > > $ cc imagespeed.c -o imagespeed > $ ./imagespeed 10000 > Testing privacy mask loop (repeat 10000 times) > Execution time (original loop): 25 sec. > Execution time (improved loop): 3 sec. > $ cc -O2 imagespeed.c -o imagespeed > $ ./imagespeed 100000 > Testing privacy mask loop (repeat 100000 times) > Execution time (original loop): 64 sec. > Execution time (improved loop): 4 sec. > > Doing a flat loop with minimal calculations about double the speed. > Preceding it with the "unsigned long" loop multiply the speed by an > additional factor of 8 on my 64 bit PC. To my surprise, the gain is > much lower (but still dramatic) when compiled without optimization. > > I attached the source file of my performance test. It simulates the > same struct indirections as used by motion.c and starts by generating > a binary pattern for the current image and another for the mask, > calculates the masked image using each method and compare the binary > result. If the check passed, it runs the performance tests. That is > the full extend of my testing thus far. > > Comments are welcome. I have prepared a modified version of motion.c, > but I still have to test it. > > Thanks. > > Pascal. > > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > > > _______________________________________________ > Motion-user mailing list > Motion-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/motion-user > https://motion-project.github.io/ > > Unsubscribe: https://lists.sourceforge.net/lists/options/motion-user -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ------------------------------ _______________________________________________ Motion-user mailing list Motion-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/motion-user End of Motion-user Digest, Vol 130, Issue 1 *******************************************