Webcam sketch "mirror" not working

I’m just getting started with processing, attempting to learn the ropes, and I was watching a youtube tutorial where he pulls up the built in sketch “mirror” under “libraries > video > capture > mirror” and my webcam lights up for a few seconds before turning off, and video never appears on the screen. No errors are shown, no problem compiling, which makes it difficult to troubleshoot the problem.

System specs:
MacBook Pro 2019
OSX 10.14.6

I’d appreciate any points in the right direction because I don’t even know where to start. My first guess is an OS compatibility issue but don’t know what I would do to fix that.

edit:

I’ve since tried several sketches involving the webcam, and none work. Are there any known issues with it?

1 Like

Welcome to the sketches!

I’m on a 2015 Pro, never had a problem. If you’ve tried multiple sketches, it definitely sounds like a local issue. I’m just shooting in the dark at this point, but it might be a local security setting.

Does this in-browser sketch work for you?
https://p5js.org/examples/dom-video-capture.html

1 Like

It is most likely an issue with the version of gstreamer, the “old” library does not work with gstreamer-1.0+ which is what recent linux and presumably newer Mac have. There is beta version of video library available that supports gstreamer-1.0+, however you will need to modify your sketches to get them to work, might well work with test capture sketch though. Basically you have to name the Camera you are using. See Video library to use new GStreamer bindings and my JRubyArt example https://github.com/ruby-processing/JRubyArt-examples/blob/master/processing_app/library/video/capture/mirror.rb.

1 Like

Good thinking! I didn’t even know there WAS a browser version of processing, great method to troubleshoot! It DOES work just fine in the browser version, camera and all. I suppose worst case scenario I could just use the browser version. I wonder if I can add custom libraries to it?

I tried to give processing permission to use my camera, but couldn’t quite figure out how. I settled for adding it to the accessibility list under the security and privacy tab, but no luck. Video doesn’t show up.

I’m going to give @monkstone idea, but my programing knowledge is VERY beginner, so I’m not confident I can pull it off, but I’m gonna try it.

1 Like

Hmm, I just downloaded it and installed it to test it out, but got a lot of errors and I’m not sure where to begin.

“processing.app.SketchException: Badly formed character constant (expecting quote, got i)
at processing.mode.java.preproc.PdePreprocessor.checkForUnterminatedMultilineComment(PdePreprocessor.java:831)
at processing.mode.java.preproc.PdePreprocessor.write(PdePreprocessor.java:868)
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:253)
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:155)
at processing.mode.java.JavaBuild.build(JavaBuild.java:122)
at processing.mode.java.JavaBuild.build(JavaBuild.java:104)
at processing.mode.java.JavaMode.handleLaunch(JavaMode.java:122)
at processing.mode.java.JavaEditor.lambda$0(JavaEditor.java:1099)
at java.lang.Thread.run(Thread.java:748)”

I’m not asking anybody to do the work for me, and I really want to wrap my head around what I need to do to alleviate this issue. Is this a java library I need to install? I searched “java” in the add library section, but I didn’t see anything that looked like it was what I wanted. I’ll keep searching.

Thank you both for your pointers!

Just an update. Just because I run into this kind of thing fairly frequently, I’ve taken to installing windows with bootcamp on my macs, so I just tried this out on windows 10, and it works fine. I am fine with that for now, and I appreciate both of your help with the issue. Technological growing pains is all.

2 Likes

You’re in luck! P5.js has some great libraries that are meant to operate within the Processing structure(draw(), setup(), etc) but, because P5js is itself just a JS library, you can actually use anything in the general javascript ecosystem! :exploding_head:

1 Like

@sargentpilcher There is guide to manual install of processing libraries. Which you might find useful. The beta video library leaves a lot to be desired but works reasonably well.

1 Like

Your problem with the webcam on macOS is probably this issue (which has documented workarounds, although no fix yet):

2 Likes