0

model no: RPi 3 B Software: Python 3.5.3

Problem: I am using opencv 3.4 .I was trying to draw a line using function cv2.line().But it returns nothing.But the same code was working fine in my laptop using opencv 3.3. the uploaded code was- import numpy as np import cv2 img = np.zeros((512,512,3), np.uint8) img = cv2.line(img,(0,0),(511,511),(255,0,0),5) cv2.imshow('line',img)

2

If it is a python script you need to add

cv2.waitKey(1) 

right after

cv2.imshow('line',img)

If you are running your code on the python console, you will need to run cv2.startWindowThread() first.

import numpy as np
import cv2
img = np.zeros((512,512,3), np.uint8)
img = cv2.line(img,(0,0),(511,511),(255,0,0),5)
cv2.startWindowThread()
cv2.namedWindow('line')
cv2.imshow('line',img)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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