loading
 
RoboRealm VCam driver??
Christian  [13 posts]
7 years
Hi,

I am trying to get RoboRealm VCam to work with my java (JMF)program all to no success.

I have the virtual driver installed as instructed on http://www.roborealm.com/help/Virtual_Camera_Driver.php

I tested the virtual driver to make sure it was properly installed by making a call to it from my program and it worked! but when i turn on RoboRealm, it does not connect to the same webcam dispite using the main camera driver?? I have also installed DirectX?

"3. RoboRealm then send its processed image to its VCam driver (ensure that the Options->Other->Activate VCam is set)" This is the part that is not working.

On the installation note it says when i call the VCam driver from my program it should only show a blank screen right? but the reverse is the case.

Please help it is urgent.

here is my program if you are interrested. It works fine.

import javax.swing.*;
import java.io.*;
import javax.media.*;
import java.nio.Buffer;
import javax.media.Buffer.*;
import javax.media.format.*;
import javax.media.util.*;
//import javax.media.control.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import com.sun.image.codec.jpeg.*;


public class camagain extends Panel implements ActionListener {

    public static Player player;
    public CaptureDeviceInfo DI;
    public MediaLocator ML;
    public JButton CAPTURE;
    public Buffer BUF;
    public Image img;
    public VideoFormat VF;
    public BufferToImage BtoI;
    public ImagePanel imgpanel;
    public javax.swing.Timer timer = new javax.swing.Timer(200, this); // 200ms is too fast increase it to suit your need

    public camagain() {
        setLayout(new BorderLayout());
        setSize(160, 120);

        imgpanel = new ImagePanel();
        CAPTURE = new JButton("Capture");
        CAPTURE.addActionListener(this);

        String str1 = "vfw:RoboRealm, Virtual Camera:0";
        String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";
        DI = CaptureDeviceManager.getDevice(str1);
        ML = new MediaLocator("vfw://0");

        try {
            player = Manager.createRealizedPlayer(ML);
            player.start();
            Component comp;
            if ((comp = player.getVisualComponent()) != null) {
                add(comp, BorderLayout.NORTH);
            }
            add(CAPTURE, BorderLayout.CENTER);
            add(imgpanel, BorderLayout.SOUTH);
            //Thread.sleep(5000);     // this is important, otherwise you may get NPE somewhere, needs polishing ;-)
            timer.start();                // start timer
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Frame f = new Frame("SwingCapture");
        camagain cf = new camagain();   // I didn't had 'SwingCapture, so I added camgain.....

        f.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                playerclose();
                System.exit(0);
            }
        });

        f.add("Center", cf);
        f.pack();
        f.setSize(new Dimension(160, 120));
        f.setVisible(true);
    }

    public static void playerclose() {
        player.close();
        player.deallocate();
    }

    public void actionPerformed(ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

//    public void actionPerformed(ActionEvent e) {
//        if (e.getSource() instanceof JComponent) {
//            JComponent c = (JComponent) e.getSource();
//            if (c == CAPTURE) {
//                action();  // maoved every thing to new method action()
//            }
//        } else if (e.getSource() instanceof javax.swing.Timer) {
//            action();       // timer event , call action() again
//        }
//    }

//    public void action() {    // your action handler code.....
//        // Grab a frame
//        FrameGrabbingControl fgc = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
//        BUF = fgc.grabFrame();
//
//        /* Make sure we actually got a frame */
//        if (BUF == null)
//            return;
//
//        // Convert it to an image
//        BtoI = new BufferToImage((VideoFormat) BUF.getFormat());
//        img = BtoI.createImage(BUF);
//
//        /* Make sure we actually got an image */
//        if (img == null)
//            return;
//
//        // show the image
//        imgpanel.setImage(img);
//
//        // save image
//        saveJPG(img, "d:\\test.jpg");
//
//    }


    class ImagePanel extends Panel {

        public Image myimg = null;

        public ImagePanel() {
            setLayout(null);
            setSize(320, 240);
        }

        public void setImage(Image img) {
            this.myimg = img;
            repaint();
        }

        public void paint(Graphics g) {
            super.paint(g);
            g.drawImage(myimg, 0, 0, this);
        }
    }

    public static void saveJPG(Image img, String s) {
        BufferedImage bi = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = bi.createGraphics();
        g2.drawImage(img, null, null);
        FileOutputStream out = null;
        try {
            out = new FileOutputStream(s);
        } catch (java.io.FileNotFoundException io) {
            System.out.println("File Not Found");
        }

        JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
        JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
        param.setQuality(0.5f, false);
        encoder.setJPEGEncodeParam(param);

        try {
            encoder.encode(bi);
            out.close();
        } catch (java.io.IOException io) {
            System.out.println("IOException");
        }
    }

}
Anonymous 7 years
Hi Christian,

I'm not sure I understand what the issue is. You mention that you can connect to the VCam webcam driver from your application so that seems ok.

1. What happens when you drag an image into RoboRealm. Does your application see that image?

2. If so then things on your side are working ok. The next is just to connect RoboRealm to the webcam you want to connect to. Thus you should be able to press the camera button in the main RoboRealm GUI and select the appropriate camera using the options button->Video Tab->webcam dropdown menu. Pressing ok should then start that webcam and show the images in RoboRealm .... or is that the part that is not working?

Alternatively, you could use the RoboRealm API to connect directly to RoboRealm and request an image ... the way you are doing it should work but just in case you are looking for additional control the API would be a better choice.

http://www.roborealm.com/help/API.php

STeven.
Christian  [13 posts] 7 years
Thanks Steven,

The problem is, RoboRealm seem to be using the VCam as well. When i connect my program, it tells me that another application is using the same driver even if RoboRealm is connected to the original web cam driver!.
Just to make sure i was on the right track, i downloaded Amcap which worked but there was also an exception with that. It wasn't displaying the processed (Grayscale & Threshold) frame on Amcap.

All i want is to grab processed live frames from RoboRealm to put into my program.  Can the RoboRealm API do this for me?
Anonymous 7 years
RoboRealm would be accessing the VCam (in order to give it images) but that should not prevent anything from connecting to it. If Amcap worked then something strange may be going on in the Java side of things since Amcap would not work if RR was doing something wrong.

In order to show the processed image be sure to select the Options->Other->Virtual Camera->Current or leave blank. Then the processed image should show up.

The API can be used to grab an image. See the docs at

http://www.roborealm.com/help/API.php

and a Java example at

http://www.roborealm.com/downloads/API.zip

which is what most folks use in your situation.

It is possible that the Java media access does not like the VCam driver ... since it is not really a hardware device.

STeven.
Christian  [13 posts] 7 years
Thanks Steven, I think thats all. I will work my head round the API.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index