# Camera only shows black screen. How to fix?

**URL:** <https://discourse.processing.org/t/camera-only-shows-black-screen-how-to-fix/1395>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [June 30, 2018, 8:08pm UTC](https://discourse.processing.org/t/camera-only-shows-black-screen-how-to-fix/1395 "2018-06-30T20:08:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![WindJammer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/windjammer/32/320_2.png) [@WindJammer](https://discourse.processing.org/u/WindJammer)\
**Post date:** [June 30, 2018, 8:08pm UTC](https://discourse.processing.org/t/camera-only-shows-black-screen-how-to-fix/1395/1 "2018-06-30T20:08:11Z")

</div>

It’s a weird thing and **only** occurs in this sketch i’m working on. So it can’t be a problem with my (laptop) webcam.

[https://drive.google.com/drive/folders/1Vu4FjusiwR7pa1BzRV1mA\_I5yCBbbgT2?usp=sharing](https://drive.google.com/drive/folders/1Vu4FjusiwR7pa1BzRV1mA_I5yCBbbgT2?usp=sharing)

My sketch has 3 states.

State 1: -take a snapshot from the webcam when clicking the Left mouse button  
-apply chroma keying to it (remove greens)  
-Put the snapshot in an array

State 2: -Preview the snapshots in the array in a row that moves to the left

State 3 is irrelevant for now.

The problem is that **in State 2 only black pictures are being previewed**. I didn’t have this issue until i let somebody do some tweaks to my code which i can’t remember any details about.

I couldn’t find a solution for this, my teacher didn’t manage to figure it out either.  
What I can tell is that the code consists of several intergrated code-examples from the web and from school, so there are a couple of things in the code I don’t even understand myself. Yeah I’m a big noob.

Anyway, Thanks by advance for any help.  
And if you think my sketch is a mess, sorry for my sketch being a mess…

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [July 1, 2018, 1:33am UTC](https://discourse.processing.org/t/camera-only-shows-black-screen-how-to-fix/1395/2 "2018-07-01T01:33:31Z")

</div>

How many lines of code do you have there? Can you paste it here?

Kf

---

<div class="post-metadata">

**Author:** ![WindJammer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/windjammer/32/320_2.png) [@WindJammer](https://discourse.processing.org/u/WindJammer)\
**Post date:** [July 1, 2018, 7:56am UTC](https://discourse.processing.org/t/camera-only-shows-black-screen-how-to-fix/1395/3 "2018-07-01T07:56:01Z")

</div>

A lot. That’s why I didn’t.

I can send each tab in a pastebin if you like.

State\_ProgrammingV3\_Kasper [https://pastebin.com/QM5JnVkM](https://pastebin.com/QM5JnVkM)

SetupCam: [https://pastebin.com/ice4gGUf](https://pastebin.com/ice4gGUf)

Arduino: [https://pastebin.com/3Luvx2AF](https://pastebin.com/3Luvx2AF)

STATE 1: [https://pastebin.com/AdQw6u3q](https://pastebin.com/AdQw6u3q)

STATE 2: [https://pastebin.com/VQN5dcGg](https://pastebin.com/VQN5dcGg)

STATE 3: (irrelevant): [https://pastebin.com/Ugi1Vk3h](https://pastebin.com/Ugi1Vk3h)

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [July 1, 2018, 6:08pm UTC](https://discourse.processing.org/t/camera-only-shows-black-screen-how-to-fix/1395/4 "2018-07-01T18:08:07Z")

</div>

Yes, you have an arduino there which means your sketch will not run without changing some things in your code. This is why an mcve is the way to go: a simple sketch that runs and demonstrates the problem. For the time being, can you indicate what section is suspicious, what lines you suspect the problem resides at?

Kf

---

<div class="post-metadata">

**Author:** ![WindJammer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/windjammer/32/320_2.png) [@WindJammer](https://discourse.processing.org/u/WindJammer)\
**Post date:** [July 2, 2018, 1:43pm UTC](https://discourse.processing.org/t/camera-only-shows-black-screen-how-to-fix/1395/5 "2018-07-02T13:43:30Z")

</div>

Nevermind, got the problem solved by one of my teachers.  
I simply forgot to add camera.read().

Anyway, thanks for your help.

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [July 2, 2018, 8:36pm UTC](https://discourse.processing.org/t/camera-only-shows-black-screen-how-to-fix/1395/6 "2018-07-02T20:36:02Z")

</div>

Glad it is solved. It was a simple solution and a very tiny bug.

Kf
