Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createCapture() and loadPixels() in 0.7.2+ not working? #3549

Closed
shiffman opened this issue Feb 28, 2019 · 9 comments
Closed

createCapture() and loadPixels() in 0.7.2+ not working? #3549

shiffman opened this issue Feb 28, 2019 · 9 comments

Comments

@shiffman
Copy link
Member

Nature of issue?

  • Found a bug

Most appropriate sub-area of p5.js?

  • Image

I am not able to get pixels of a video from a webcam in version 0.7.2 or 0.7.3. The code works in 0.7.1 returning a non-zero pixel length.

let video;

function setup() {
  createCanvas(640, 480);
  video = createCapture(VIDEO);
}

function draw() {
  video.loadPixels();
  print(video.pixels.length);
}
@Ajayneethikannan
Copy link
Contributor

I think this was corrected through #3504 by @Spongman !

@andy5090
Copy link

I got the same issue. I downloaded p5.js complete and cannot get any pixels from webcam. But in web editor it works. So I changed p5.dom.js to 0.6.1 then it works.

@Spongman
Copy link
Contributor

can someone comfirm that #3504 does actually fix this issue with webcams? i tested it with video playback, but i don't have a working webcam on my dev machine.

@Ajayneethikannan
Copy link
Contributor

Ajayneethikannan commented Mar 12, 2019

@Spongman It works well with webcam ,
I tried with this code

let video;
let s, t;
function setup() {
  createCanvas(640, 480);
  video = createCapture(VIDEO);
  s = random(width);
  t = random(height);
}

function draw() {
  noStroke();
  video.loadPixels();
  s += 0.1;
  t += 0.2;
  let x1 = noise(s)*width;
  let y1 = noise(t)*height;
  let col = video.get(x1, y1);
  console.log(col);
  fill(col[0], col[1], col[2],200);
  rect(x1, y1, 20, 20);
  for(let i =0;i< 3;i++)
  {
  let x2 = random(width);
  let y2 = random(height);
  if(x2 > 3*width/4 || x2 < width/4 || y2> 3*height/4 || y2 <height/4)
  {
    
    let col = video.get(x2, y2);
    fill(col[0], col[1], col[2], 150);
    circle(x2, y2, 20);
  }
}
  
}

And it is does work on very iteration of the draw loop (checking get)
The code given by @shiffman also works correctly (checking loadPixels)

@Spongman
Copy link
Contributor

Great, thanks for doing that!

@stalgiag
Copy link
Contributor

Thanks @Ajayneethikannan ! I think we should leave this issue open until the fix makes it into a release (end of month?) so that people find the issue more easily when researching the bug.

@timkoerner
Copy link

In the meantime #3504 has been merged, right?

@limzykenneth
Copy link
Member

@koernertim Yes, if you need to fix now you can build the library from master.

@lmccart
Copy link
Member

lmccart commented Apr 8, 2019

this has been fixed in 0.8.0 out today

@lmccart lmccart closed this as completed Apr 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants