You are not logged in.
Pages: 1
I'm trying to get Opencv to work and by running the PixelBotTest.py script below I get a window that is just 64 by 64 literal pixels and not 64 by 64 scaled with 8 as it should do in the PixelBot class.
When I comment out cv2.resizeWindow it does the same thing so it looks like it's just ignoring it?
I tried to use WINDOW_OPENGL but that just makes it extremely blurry.
***PixelBot.py***
import cv2
import numpy as np
class PixelBot:
def __init__(self, x: int = 64, y: int = 64, windowScale: float = 8) -> None:
self.map = np.zeros([x,y,1], dtype=np.uint8)
self.pos = [0, 0]
self.map.fill(255)
cv2.namedWindow("PixelBot", cv2.WINDOW_NORMAL)
cv2.resizeWindow("PixelBot", x * windowScale, y * windowScale)
def startPixelBot(self, x:int = 0, y: int = 0):
self.pos = [x, y]
self.setPos(self.pos[0], self.pos[1])
def setPos(self, x:int, y:int):
self.map[self.pos[0], self.pos[1]] = 255
self.pos = [x, y]
self.map[self.pos[0], self.pos[1]] = 0
cv2.imshow("PixelBot", self.map)
***PixelBotTest.py***
from PixelBot import PixelBot
import cv2
bot = PixelBot()
bot.startPixelBot()
for i in range(500):
bot.setPos(i,i)
cv2.waitKey(1000)
Offline
Pages: 1