Ask Your Question
0

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

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

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):
    print(i)
    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))    

plt.figure()
plt.imshow(im)

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

Comments

it's probably scaled down too much, vertically

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

1 answer

Sort by ยป oldest newest most voted
1

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

berak gravatar image

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

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

image description

cv2.imshow("lines", im)
cv2.waitKey()

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

edit flag offensive delete link more

Question Tools

1 follower

Stats

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

Seen: 103 times

Last updated: Nov 08 '18