Camera only shows black screen. How to fix?

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

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…

1 Like

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

Kf

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

SetupCam: https://pastebin.com/ice4gGUf

Arduino: https://pastebin.com/3Luvx2AF

STATE 1: https://pastebin.com/AdQw6u3q

STATE 2: https://pastebin.com/VQN5dcGg

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

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

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

Anyway, thanks for your help.

1 Like

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

Kf