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");
}
}
}
|
|