0

Please consider the following (I am using Mathematica 8) :

mask = DensityPlot[-Exp[-(x^2 + y^2)/5], {x, -4, 4}, {y, -3, 4}, 
       Axes -> None, Frame -> None, Method -> {"ShrinkWrap" -> True}, 
       ColorFunction -> GrayLevel, ImageSize -> 512];

       Show[ImageFilter[Mean[Flatten[#]] &, CurrentImage[], 20, 
            Masking -> mask], ImageSize -> 512]

using Sjoerd solution on Can we generate "foveated Image" in Mathematica.

I would like this to be dynamic. Right now it only takes a picture. What would be the best way to get this to work "live" without crashing my computer during my presentation ? Could I adjust the refresh rate ? Manipulate the mask ? Stop the "video mode" to take a picture ?

Community
  • 1
  • 1
500
  • 6,509
  • 8
  • 46
  • 80
  • I get an error when I run your code in V 8.01, "Show::gtype: ImageFilter is not a type of graphics" CurrentImage::checkcam: Mathematica was unable to connect to a camera. Check that a camera is properly connected and that it is not currently in use by another application – Nasser Sep 19 '11 at 01:31
  • 1
    @Nasser Check that a camera is properly connected and that it is not currently in use by another application :) – Dr. belisarius Sep 19 '11 at 01:56
  • @500 You should also indicate in your question that you're using Mma 8 or tag it with [tag:mathematica-8]. I can't try out most of your questions as they don't run on v7 (which I use)... – abcd Sep 19 '11 at 03:22

2 Answers2

2

Just wrap your Show in Dynamic and it will update as fast as it can. Combine with Refresh to set a refresh rate. Or use a timed background task.

The result is a bit slow though as the handcrafted blur filter takes too long. A better alternative would be something like:

mask = DensityPlot[-Exp[-(x^2 + y^2)/5], {x, -4, 4}, {y, -3, 3}, 
   Axes -> None, Frame -> None, Method -> {"ShrinkWrap" -> True}, 
   ColorFunction -> GrayLevel, ImageSize -> {320, 240}];

ImageCompose[im = CurrentImage[], SetAlphaChannel[Blur[im, 20], mask]]//Dynamic

which updates in real time. Note that I have changed the image dimensions of the mask to fit the size of my laptop camera. The x and y range ratio should be the same as the camera's aspect ratio.

enter image description here

Remember, as mentioned before, this only fakes visual blurring. It is far from reality.

Sjoerd C. de Vries
  • 16,122
  • 3
  • 42
  • 94
  • Thank You Sjoerd. I know it is a rough estimation of visual blurring . I think you would be interested in this : http://www.jeremyfreeman.net/public/downloads/Freeman-Simoncelli-2011-Metamers.pdf – 500 Sep 19 '11 at 11:24
  • I am really curious about what you are doing. I browsed your publications and I find similarities with my advisor`s ( http://www.psych.nyu.edu/maloney/ ). What direction are you heading into now ? – 500 Sep 19 '11 at 13:32
1

Never used a camera with Mma, but it seems that by using ImageCapture[] you can specify the Frame Rate and other parameters.

Then use CurrentImage[] in a "loop" to process whatever you want. You can even stop the device from the ImageCapture[] interface.

Dr. belisarius
  • 60,527
  • 15
  • 115
  • 190