|
Author |
Topic: Replicate / arraycopy (Read 654 times) |
|
itpshiffman
|
Replicate / arraycopy
« on: Apr 15th, 2004, 5:49pm » |
|
Hello all, I'm creating a simple example where a frame of live video is copied into a BImage at some given time (for example, on a mouse click). For some reason, however, I can't get replicate or arraycopy to work with a reference to video.pixels. The same code works, however, if I copy from a BImage pixel array, i.e. BImage myImage = loadImage("someimage"); BImage savedFrame = new BImage(w,h); BeginVideo(w,h,#); works: savedFrame.replicate(myImage, 0, 0, myImage.width, myImage.height, 0, 0, savedFrame.width, savedFrame.height); does not work: savedFrame.replicate(video, 0, 0, video.width,video.height,0,0,savedFrame.width,savedFrame.height); works: System.arraycopy(myImage.pixels,0,savedFrame.pixels,0,myImage.pixels.len gth); does not work: System.arraycopy(video.pixels,0,savedFrame.pixels,0,video.pixels.length) ; image(savedFrame,0,0); Any suggestions would be greatly appreciated! Best, Dan http://www.shiffman.net/
|
« Last Edit: Apr 15th, 2004, 5:49pm by itpshiffman » |
|
|
|
|
toxi_ Guest
|
Re: Replicate / arraycopy
« Reply #1 on: Apr 15th, 2004, 7:15pm » |
|
hey dan, am not really sure why this wouldn't work for you. just did a little test myself and it seems to work fine... Code:BImage img; boolean newframe=false; void setup() { size(320,240); beginVideo(width,height,8); } void loop() { if (newframe) { image(img,0,0); } } void videoEvent() { img=video.copy(); newframe=true; } |
| even though i'm not using System.arraycopy() explicitly, it is used by the BImage.copy() method... will dig deeper & keep you posted!
|
|
|
|
itpshiffman
|
Re: Replicate / arraycopy
« Reply #2 on: Apr 15th, 2004, 7:51pm » |
|
I think there's perhaps something off w/ my machine / java environment, etc. Your example doesn't work either. . . in fact, i got this error message: java.lang.NullPointerException at Temporary_109_4104.videoEvent(Temporary_109_4104.java:16) at BVideo.run(BVideo.java:337) at java.lang.Thread.run(Thread.java:536) which would lead me to believe that something is wrong w/ video capturing locally. nevertheless, this works just fine: BImage img; boolean newframe=false; void setup() { size(320,240); beginVideo(width,height,; } void loop() { if (newframe) { image(video,0,0); //image(img,0,0); } } void videoEvent() { //img=video.copy(); newframe=true; } d.
|
|
|
|
|