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

**URL:** https://discourse.processing.org/t/windows-10-how-to-use-directshow-to-read-camera-image/21689
**Category:** Libraries
**Created:** [June 8, 2020, 11:21pm UTC](https://discourse.processing.org/t/windows-10-how-to-use-directshow-to-read-camera-image/21689 "2020-06-08T23:21:42Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![marianalimoes](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@marianalimoes](https://discourse.processing.org/u/marianalimoes)
#### Post date: [June 8, 2020, 11:21pm UTC](https://discourse.processing.org/t/windows-10-how-to-use-directshow-to-read-camera-image/21689/1 "2020-06-08T23:21:42Z")

</div>

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](https://forum.processing.org/two/discussion/14403/camera-video-image-slow) 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](http://www.magicandlove.com/blog/2012/04/10/directshow-for-processing/), 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,  
Mariana

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [June 9, 2020, 10:05am UTC](https://discourse.processing.org/t/windows-10-how-to-use-directshow-to-read-camera-image/21689/2 "2020-06-09T10:05:14Z")

</div>

Hi,

Welcome to the forum! 🙂

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 :

```auto
import de.humatic.dsj.*;

```

So if you succeeded downloading the [DirectShow libraries](http://www.humatic.de/htools/dsj/), just put them in your sketch folder (root folder).

---

<div class="post-metadata">

### Author: ![marianalimoes](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@marianalimoes](https://discourse.processing.org/u/marianalimoes)
#### Post date: [June 9, 2020, 10:43am UTC](https://discourse.processing.org/t/windows-10-how-to-use-directshow-to-read-camera-image/21689/3 "2020-06-09T10:43:50Z")

</div>

Hello! Thank you! 🙂

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

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.

```auto
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);
    img.updatePixels();
    return img;
  }
 
  public void propertyChange(java.beans.PropertyChangeEvent e) {
    switch (DSJUtils.getEventType(e)) {
    }
  }
}

```

Thanks very much!

---

<div class="post-metadata">

### Author: ![marianalimoes](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@marianalimoes](https://discourse.processing.org/u/marianalimoes)
#### Post date: [June 9, 2020, 1:41pm UTC](https://discourse.processing.org/t/windows-10-how-to-use-directshow-to-read-camera-image/21689/4 "2020-06-09T13:41:27Z")

</div>

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](http://www.magicandlove.com/blog/2012/04/10/directshow-for-processing/), 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.

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [June 9, 2020, 2:43pm UTC](https://discourse.processing.org/t/windows-10-how-to-use-directshow-to-read-camera-image/21689/5 "2020-06-09T14:43:49Z")

</div>

Glad it worked, have a great coding day! 😉
