This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
accessing picamera via python
#1
Hi!
Since Monday I've got a tinker board. I'm using opencv (version 3.3.1) and want to use the picamera v2 but I can't access it. I used the tinker board CSI-camera wiki as reference.
I can accessing it via the terminal
Code:
gst-launch-1.0 v4l2src ! videoconvert ! autovideosink
command
What command should I use if I want to get the camera image via cv2.VideoCapture () ?

Thanks in advance!!

Jan-Willem
Reply
#2
As at https://tinkerboarding.co.uk/wiki/index....CSI-camera

Code:
cap = cv2.VideoCapture("v4l2src ! video/x-raw,format=NV12,width=640,height=480 ! videoconvert ! appsink")

while cap.isOpened():
   ret, frame = cap.read()
Reply
#3
Thank you, both
Code:
while cap.isOpened():
and
Code:
while True
won't give access to the camera. I put a
Code:
print('frame', frame)
in the loop to see what information comes through. In the first case noting happens at all and in the second case the print gives 'none'

Jan-Willem
Reply
#4
Anyone?

This is my python code:
Code:
import cv2
import sys
import os
import time

cap = cv2.VideoCapture("v4l2src ! video/x-raw,format=NV12,width=640,height=480 ! videoconvert ! appsink")
cv2.setNumThreads(4)

time.sleep(1.0)

while cap.isOpened:
    ret, webcam = cap.read()
    
    cv2.imshow('webcam',webcam)

    
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows

and this is the traceback I get:
Code:
Traceback (most recent call last):
  File "/home/linaro/Desktop/2.py", line 14, in <module>
    cv2.imshow('webcam',webcam)
cv2.error: /home/linaro/opencv-3.3.1/modules/highgui/src/window.cpp:331: error: (-215) size.width>0 && size.height>0 in function imshow
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)