SimpleARToolKit dosn't work with PImage with the format=1 ?
in
Contributed Library Questions
•
2 years ago
The goal:
I want to use the SimpleARToolKit in processing. The demo programs use all the Library JMyron to get the images from the webcam, although there was written
The way:
So I'm decided to try to get the PImage with the help of JMF. I learnd by the examples of timcam package.
With my function getPImage I get PImages into processing:
My problem
It seems to work very well. Each new image of the webcam can be displayed in processing. But the SimpleARToolKit dosn't work with my PImages in the following code:
Now my question:
Has anybody an idea to
Thanks to read my long prolog.
I want to use the SimpleARToolKit in processing. The demo programs use all the Library JMyron to get the images from the webcam, although there was written
"The PImage variable img contains the latest capture image. It does not matter to create the img by using JMyron, Capture object, JMF or GStream, etc."
http://www.bryanchung.net/?page_id=415
And I know the old never ending stroy with the JMyron because of finding the native dll's.
The way:
So I'm decided to try to get the PImage with the help of JMF. I learnd by the examples of timcam package.
With my function getPImage I get PImages into processing:
- public PImage getPImage() {
- Buffer buf = null;
- Image img = null;
- System.out.println( "JWorCam.getPImage" );
- FrameGrabbingControl fgc = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
- // the player may be in the started state, but it takes a few tries before
- // we get a valid frame!
- do {
- buf = fgc.grabFrame();
- }
- while(buf.getLength() == 0);
- BufferToImage btoi = new BufferToImage((VideoFormat) buf.getFormat());
- img = btoi.createImage(buf);
- PImage pimg = new PImage( (java.awt.Image)img );
- return pimg;
- }
It seems to work very well. Each new image of the webcam can be displayed in processing. But the SimpleARToolKit dosn't work with my PImages in the following code:
- import javax.media.*;
- import JWorCam_Package.*;
- import processing.opengl.*;
- import pARToolKit.SimpleARToolKit;
- JWorCam j;
- PImage img;
- SimpleARToolKit ar;
- int capWidth, capHeight;
- void setup() {
- size(640, 480, OPENGL);
- capWidth = 320;
- capHeight = 240;
- j = new JWorCam();
- j.start ("vfw:Microsoft WDM Image Capture (Win32):0");
- img = createImage(capWidth, capHeight, ARGB);
- ar = new SimpleARToolKit(this, capWidth, capHeight);
- ar.loadPattern("patt.hiro", 80, 0.0f, 0.0f);
- ar.register("showBox");
- stroke(200,200,0);
- }
- void draw() {
- background(0);
- img = j.getPImage();
- img.updatePixels();
- println("img.format" + img.format);
- image(img,0,0,width,height);
- println("Img" +img);
- if (ar.findMatch(img,1000)) {
- ar.showObject();
- }else
- println("Pattern not found");
- }
- void showBox(SimpleARToolKit _a) {
- noFill();
- box(50);
- fill(255);
- }
Now my question:
Has anybody an idea to
- modify my function getPImage or
- to convert a PImage with format=1 to a PImage with format=2 ?
Thanks to read my long prolog.
1