Thursday, June 28, 2018

OpenCV V4l2 using Gstreamer

OpenCV V4l2 using Gstreamer

resize window

12cv2.namedWindow("visiondemo",cv2.WINDOW_FULLSCREEN)
cv2.resizeWindow('visiondemo', 1920,1080)

set fps

123cap.set(cv2.CAP_PROP_FRAME_WIDTH,1920)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT,1080)
cap.set(cv2.CAP_PROP_FPS,30)

Setup Video

Normal Setup

1cap = cv2.VideoCapture("v4l2src device=/dev/video0 ! appsink")

JPEG Setup

1cap = cv2.VideoCapture("v4l2src device=/dev/video0 do-timestamp=true ! image/jpeg, width=1920, height=1080, framerate=30/1 ! jpegdec ! videoconvert ! appsink")

TEE Setup

1cap = cv2.VideoCapture("v4l2src device=/dev/video0 do-timestamp=true ! image/jpeg, width=1920, height=1080, framerate=30/1 ! jpegdec ! tee name=t ! queue ! videoconvert ! appsink t. ! queue ! videoconvert ! videoscale ! videorate ! video/x-raw,width=640,height=480,framerate=15/1 ! v4l2sink device=/dev/video2")

Play Video

123456789101112cap = cv2.VideoCapture("v4l2src device=/dev/video0 ! appsink")

while True:
  ret, image = cap.read()
  if ret == True:
    print("capture not working")
    break
    
  key = cv2.waitKey(1)
  if (key & 0xFF) == ord('q'):
    break
    

Friday, June 22, 2018

How to add get keys for ubuntu repo in another distribution

add

deb [trusted=yes] http://archive.ubuntu.com/ubuntu trusty universe

to /etc/apt/sources.list

do apt-get update

It will complain about non existing public key. Take not of the PUB_KEY and now execute following,


apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <PUB_KEY>

This should add the key for the said repository.

Now you can execute following at it should work without any errors.

sudo apt-get update