OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

how to draw lines on a tensor?

  • Thread starter Thread starter ShinNShirley
  • Start date Start date
S

ShinNShirley

Guest
I wanna draw lines on a tensor, just like how I do on a numpy.array one :

Code:
pts = [[160, 160], [280, 280]]
mask = np.zeros([640,640]).astype(np.uint8)
mask = cv2.line(mask, *pts, (255, 255), 15)
plt.imshow(mask)
plt.show()

image show result: enter image description here

The tensor like this:

Code:
mask_t = torch.zeros([640,640],dtype=torch.uint8).to(device)

How can I do for this?
<p>I wanna draw lines on a tensor, just like how I do on a numpy.array one :</p>
<pre><code>pts = [[160, 160], [280, 280]]
mask = np.zeros([640,640]).astype(np.uint8)
mask = cv2.line(mask, *pts, (255, 255), 15)
plt.imshow(mask)
plt.show()
</code></pre>
<p>image show result:
<a href="https://i.sstatic.net/IQEe1.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/IQEe1.png" alt="enter image description here" /></a></p>
<p>The tensor like this:</p>
<pre><code>mask_t = torch.zeros([640,640],dtype=torch.uint8).to(device)
</code></pre>
<p>How can I do for this?</p>
 
Top