FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   can we capture video online and apply filter
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: can we capture video online and apply filter  (Read 671 times)
Gaurav


can we capture video online and apply filter
« on: Nov 19th, 2003, 5:11pm »

I learn processing few days back I found it easy to code. I can use it for prototyping as student of interface Design.
 
I want to do some crazy thing. I want to capture online video and apply filter to it like blur etc. Is is possible to do that in processing. Or can we use some java code. How can be incorparate processing code with Java(processing is made in java?) If you have any code, techpaper etc on this material on this please send it to me. I know littlebit of java.
 
mKoser

WWW Email
Re: can we capture video online and apply filter
« Reply #1 on: Nov 19th, 2003, 6:34pm »

basically you can't use the video-camera-feature in applets, so capturing video online is not easily done.
 
if you create a folder called /code/ within the folder of your sketch, you can include .jar files in your applet. Take a look at Amit Pitaru's example of including external .jar files for supporting Wacom boards as an example:
 
http://www.pitaru.com/jwintab_v2/
 
+ mikkel
« Last Edit: Nov 19th, 2003, 6:36pm by mKoser »  

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
mKoser

WWW Email
Re: can we capture video online and apply filter
« Reply #2 on: Nov 19th, 2003, 7:36pm »

oh, and here's a really quick example of a videofeed being blurred!  
 
Code:

/* simple videBlue
by Mikkel Crone Koser
novemeber 19th 2003
www.beyondthree.com
proce55ing.beyondthree.com
implementing blur-method by seb.cc
 
PRESS MOUSE TO BLUR VIDEOFEED
 
*/
 
void setup(){
  beginVideo(320, 240, 25);
  size(320, 240);
  background(0);
}
 
void loop(){
  tint(255, 25);
  image(video, 0, 0);
  if(mousePressed){
    // how many times should the image be blurred
    // 0 blurs the image once ... try more!
    blur(0);          
  }
}
 
// BLUR BY SEB.CC
final int WIDTH=320;
final int HEIGHT=240;
int blurCount=0;
float blurCountInc=1;
// FULL RGB DIFFUSION FILTER
// by SEB // www.seb.cc
void blur(int tt) {
  for(int ttt = 0; ttt <= tt; ttt++){
    int index,R,G,B,left,right,top,bottom;
    for(int j=0;j<WIDTH;j++) {
      for(int i=0;i<HEIGHT;i++) {
        index=i*WIDTH+j;
 
        // Wraparound offsets
        if(j>0) left=-1; else left=WIDTH-1;
        if(j==(WIDTH-1)) right=-WIDTH+1; else right=1;
        if(i>0) top=-WIDTH; else top=(HEIGHT-1)*WIDTH;
        if(i==(HEIGHT-1)) bottom=-(HEIGHT-1)*WIDTH; else bottom=WIDTH;
 
        // Calculate the sum of n neighbors
        R=(pixels[left+index]>>16) & 255; // left middle
        R+=(pixels[right+index]>>16) & 255; // right middle
        R+=(pixels[index]>>16) & 255; // middle middle
        R+=(pixels[index+top]>>16) & 255; // middle top
        R+=(pixels[index+bottom]>>16) & 255; // middle bottom
        R=(R/5);
 
        G=(pixels[left+index]>>8) & 255; // left middle
        G+=(pixels[right+index]>>8) & 255; // right middle
        G+=(pixels[index]>>8) & 255; // middle middle
        G+=(pixels[index+top]>>8) & 255; // middle top
        G+=(pixels[index+bottom]>>8) & 255; // middle bottom
        G=(G/5);
 
        B=pixels[left+index] & 255; // left middle
        B+=pixels[right+index] & 255; // right middle
        B+=(pixels[index] & 255); // middle middle
        B+=pixels[index+top] & 255; // middle top
        B+=pixels[index+bottom] & 255; // middle bottom
        B=(B/5);
        pixels[index]=(R<<16)+(G<<8)+B;
      }
    }
  }
}

 
but, as mentioned above - this will NOT work as an applet, it will only worg if you connect a camera and run the code in the P5-environemt.
 
i hope that helps
+ mikkel
« Last Edit: Nov 19th, 2003, 8:05pm by mKoser »  

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
madmerv
Guest
Email
Re: can we capture video online and apply filter
« Reply #3 on: Nov 19th, 2003, 10:39pm »

it might be interesting to have it datamine the 'net for video sources, and then feed the sources through an appplet; sorta a "Gods Eye View" of video on the 'net...
 
i dunno i felt this was a good idea before...
 
(still is)
 
have you ever played with the video features of AVS with winamp3?  I think that stuff is quite phenomenal, and offers some amazing insights into the future of dynamic content
 
itpshiffman

WWW Email
Re: can we capture video online and apply filter
« Reply #4 on: Nov 21st, 2003, 9:30pm »

I've been working on this idea quite a bit and have developed a solution for grabbing an online video source (via an applet).  I should say, however, that this only works if the online video source is an image file that auto-refreshes (so it's not really a live video stream or quicktime movie, etc.)
 
I'm using a PHP script stored in the applet's local directory to load an image:
 
-----------------------
<?php
 header("Content-Type: image/jpeg");
 $url = $_GET["url"];
 readfile($url)  
?>
-----------------------
 
And then I load the image via the PHP ( over and over again within my applet (in a separate thread).  If you don't use a separate thread, your applet will "pause" while it's loading the image.
 
BImage b = loadImage("img2.php?url=http://207.251.86.248/cctv20.jpg");
 
-----------------------
 
This applet I made loads images from 6 NYC traffic cameras and makes some weird looking graphics based on them. . .
 
http://stage.itp.nyu.edu/~dts204/proce55ing/test1/lifeny.html
 
One question -- am i potentially wreaking havoc on my server by refreshing these 6 images over and over and over again?  Should I perhaps incoporate a delay?
 
Best,
Dan
 
Pages: 1 

« Previous topic | Next topic »