(Windows 10) How to use DirectShow to read camera image

Hello, I am new here in the forum, so I hope I’m posting this issue correctly.

As it is already known in the microsoft surface community, some programs don’t read the camera correctly. Before, it used to happen with video conferencing apps, and although that has already been sorted out, Processing 3 still holds the same problem.

Please, check this discussion for a better context.

As I don’t see any direct solution for my problem, I’ve come to understand I can use DirectShow to connect directly to the camera (as explained in the last reply to the discussion mentioned above). Here, a fellow Processing user explained how.

However, I don’t know how to “package the dsj.jar and the dsj.dll (32bit or 64bit according to your platform) into your code folder”, as it is described in the link above.

Can someone explain, like I am a 5 y/o, how to manually install that DirectShow library? And which of the wrapped packages I should even download?

Thank you very much in advance,

1 Like


Welcome to the forum! :slight_smile:

It seems that the solution is described here :

As in the article you need to copy dsj.dll and dsj.jar in sketchfolder/code

As you can see, they are importing it in the DMovie class so Processing nees to access it :

import de.humatic.dsj.*;

So if you succeeded downloading the DirectShow libraries, just put them in your sketch folder (root folder).


Hello! Thank you! :slight_smile:

Alright, I was putting it in what i assumed was the “sketchfolder”, the folder containing this single sketch. Thanks for clearing that up :slight_smile:

Now I have tested the code they published. However, it doesn’t generate any results. And I don’t understand the vocabulary it’s using: “DCapture”, “DSFilterInfo”, etc. Is there any library or references to help me understand this program? And shouldn’t I reference which camera the program should access?

Also, the problem the console tells me now is “The constructor DCapture() is never used locally” and “The method updateImage() from the type DCapture is never used locally”.

This is the code I used.

import de.humatic.dsj.*;
import java.awt.image.BufferedImage;
class DCapture implements java.beans.PropertyChangeListener {
  private DSCapture capture;
  public int width, height;
  DCapture() {
    DSFilterInfo[][] dsi = DSCapture.queryDevices();
    capture = new DSCapture(DSFiltergraph.DD7, dsi[0][0], false, 
    DSFilterInfo.doNotRender(), this);
    width = capture.getDisplaySize().width;
    height = capture.getDisplaySize().height;
  public PImage updateImage() {
    PImage img = createImage(width, height, RGB);
    BufferedImage bimg = capture.getImage();
    bimg.getRGB(0, 0, img.width, img.height, img.pixels, 0, img.width);
    return img;
  public void propertyChange(java.beans.PropertyChangeEvent e) {
    switch (DSJUtils.getEventType(e)) {

Thanks very much!

1 Like

Alright! I sorted my last question. If anyone else is having the same problem, all it takes is copying and pasting BOTH codes: the DSCapture class and the sample code beneath, as said in the same website, to implement DirectShow.

My camera works! And if its getting the back cam, all it takes is switch dsi[0][0] to dsi[0][1] to get the front camera.


Glad it worked, have a great coding day! :wink:

1 Like