Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
htxstudentdk
htxstudentdk's Profile
2
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Can't connect to my webcam! (On PC)
[0 Replies]
23-Apr-2013 11:57 PM
Forum:
Integration and Hardware
Okay guys, i have a huge problem!
I am doing af finals-projekt and i suddenly can't connect to my webcam! :/
I have tried running through almost every version since 1.5, but it won't work....
I am to do something with motion capturing, so i found this basic-code, which i used:
// Learning Processing
// Daniel Shiffman
//
http://www.learningprocessing.com
// Example 16-14: Overall motion
import processing.video.*;
// Variable for capture device
Capture video;
// Previous Frame
PImage prevFrame;
// How different must a pixel be to be a "motion" pixel
float threshold = 50;
void setup() {
size(320,240);
// Using the default capture device
video = new Capture(this, width, height, 15);
// Create an empty image the same size as the video
prevFrame = createImage(video.width,video.height,RGB);
}
void draw() {
background(0);
// You don't need to display it to analyze it!
image(video,0,0);
// Capture video
if (video.available()) {
// Save previous frame for motion detection!!
prevFrame.copy(video,0,0,video.width,video.height,0,0,video.width,video.height);
prevFrame.updatePixels();
video.read();
}
loadPixels();
video.loadPixels();
prevFrame.loadPixels();
// Begin loop to walk through every pixel
// Start with a total of 0
float totalMotion = 0;
// Sum the brightness of each pixel
for (int i = 0; i < video.pixels.length; i ++ ) {
// Step 2, what is the current color
color current = video.pixels[i];
// Step 3, what is the previous color
color previous = prevFrame.pixels[i];
// Step 4, compare colors (previous vs. current)
float r1 = red(current);
float g1 = green(current);
float b1 = blue(current);
float r2 = red(previous);
float g2 = green(previous);
float b2 = blue(previous);
// Motion for an individual pixel is the difference between the previous color and current color.
float diff = dist(r1,g1,b1,r2,g2,b2);
// totalMotion is the sum of all color differences.
totalMotion += diff;
}
// averageMotion is total motion divided by the number of pixels analyzed.
float avgMotion = totalMotion / video.pixels.length;
// Draw a circle based on average motion
smooth();
noStroke();
fill(0);
float r = avgMotion*2;
ellipse(width/2,height/2,r,r);
}
It worked fine in the beginning, but suddenly it wouldn't connect.. out of nowhere! hadn't done anything at all...
Plz help!! Thank you!
PS. I am a noob at processing...........
How to change API level in processing 2.0b6????
[1 Reply]
23-Jan-2013 01:18 AM
Forum:
Android Processing
Hi Guys, i'm new to this forum, and new to processing.
Me and my classmate are currently working on a mini-project in school, and we have to change the API level, as it is set to 10... We need it to work with API level 17 :/
Please help guys! We really need it!!
«Prev
Next »
Moderate user : htxstudentdk
Forum