Ask Your Question

Mega weird issue with opencv drawing function ?!?! [closed]

asked 2018-11-08 05:58:06 -0500

Nbb gravatar image

I have a blank image and I draw a horizontal line every 20 pixels. But the output only show the last 2 lines. I even printed i to check that that the loop is correct. Wtf ???????

import numpy as np
import matplotlib.pyplot as plt
import cv2

im = np.zeros(shape=(180,1920))
height = np.shape(im)[0]
width  = np.shape(im)[1]
cell_height = 20
cell_width = 20

for i in range(0,height,cell_height):
    cv2.line(im, (0,i), (width,i), 255)

#for i in range(0,width,cell_width):
#    cv2.line(im, (i,0), (i,height), (0,255,255))    


image description

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2018-11-08 06:10:04.208744


it's probably scaled down too much, vertically

berak gravatar imageberak ( 2018-11-08 06:11:58 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-11-08 06:09:37 -0500

berak gravatar image

updated 2018-11-08 06:13:22 -0500

your cv2 related code is working fine, use cv2.imshow() / cv2.waitKey(), not matplotlib, and you get:

image description

cv2.imshow("lines", im)

(the WTF is matplotlib, and we can't help you with it, sorry)

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-11-08 05:58:06 -0500

Seen: 26 times

Last updated: Nov 08 '18