2

If anyone has followed pyimagesearch.com's tutorial on accessing the pi camera through OpenCV and Python you will know what I am talking about. Here are the details I am in the created python environment.

source ~/.profile  
workon cv  
python video_test.py

when i execute the script it results in a black frame with nothing in it and only this output printed.

GLib-GObject-WARNING**: Attempt to add property GtkSettings::gtk-label-select-on-focus after class was initialised.

Here is the code from the site. I am not the author of this code or linked tutorial

enter image description here

enter image description here

3
  • Does the camera work from the command line? Did you follow the previous tutorial he mentions? If you did not follow the previous tutorial you don't need to use the source command. Also can you properly format all of your code and include the cmplete listing as a single entry. Commented Jun 27, 2016 at 20:05
  • yes sorry about the formatting. I am able to get a test still image from the camera. When I don't execute the script from the cv env the script is not found.
    – user202815
    Commented Jun 27, 2016 at 22:22
  • did you try "camera.start_preview()"
    – Memik
    Commented Jun 27, 2016 at 23:06

4 Answers 4

1

I encountered same situation that run the same code as yours but got a black screen. Finally, I tried to modify the code use_video_port=True to use_video_port=False and it worked. According to reference of Picamera, FPS will be lower if you change use_video_port=True to false

If use_video_port is False (the default), the burst parameter can be used to make still port captures faster. Specifically, this prevents the preview from switching resolutions between captures which significantly speeds up consecutive captures from the still port. http://picamera.readthedocs.io/en/release-1.11/api_camera.html?highlight=capture_continuous#picamera.PiCamera.capture_continuous

0

If I am not wrong you have copied the script from PyImageSearch. No prob, I copied the very same script when I was learning (and that was recent).

The script itself has no problem. Though I'd recommend ALWAYS type or paste scripts in an IDE, install NetBeans maybe, or just use IDLE, but putting it in an IDE is far more helpful. It lets you know where you went wrong.

Anyways, from the error it looks like that the problem is occuring on a particular frame. I suspect that there is some indentation problem in the code.

My recommendations-
1. Check your script for indentation problems.
2. Check the physical connection of the Pi Camera module.

And please make sure you put your code in the question and not just an image containing the code. Moreover, programming questions are out of scope for this site and should be asked on Stack Overflow.

7
  • just completed 1. and 2. still no luck. test_image.py takes a working image and pauses for the break key "q" .... does the python script need to be saved in anywhere particular is that it?
    – user202815
    Commented Jun 28, 2016 at 1:08
  • @user202815 That's unusual. On my Pi the script ran perfectly. Since you can take images with your camera the cv env is properly installed. BTW which version of Pi Camera you have? Is it the latest 1.11? It has a lot of bugs and has been toubling a lot of people (this is also discussed in the comments of the same tutorial you are following). Try reinstalling Pi camera, or just try downgrading to an older version
    – YaddyVirus
    Commented Jun 28, 2016 at 8:14
  • thanks for your response. I have the original 5MP cam. How would I download an older version, i was going off of pip install 'picamera[array]' .
    – user202815
    Commented Jun 28, 2016 at 13:40
  • @user202815 look up on the pip documentation... You can provide the version number when you are issuing the pip install command
    – YaddyVirus
    Commented Jun 28, 2016 at 14:34
  • i also entered this sudo modprobe bcm2835-v4l2 in my frenzy of trying to resolve the issue . rm command did not work do i need to undo this ?
    – user202815
    Commented Jun 28, 2016 at 14:41
0

the answer is from the blog author who responded to me.

pip uninstall camera
pip install 'camera[array]'== 1.10
1
  • Exactly what I said. You downgraded to a lower version
    – YaddyVirus
    Commented Jul 1, 2016 at 11:58
0

I guess he wanted to say

pip install 'picamera[array]'== 1.10

These lines have solved it for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.