Window too big

December 12, 2022, 17:03

robertnotfound

the windows is too big to display i try to run an opencv road sign detection import cv2 # Stop Sign Cascade Classifier xml stop_sign = cv2.CascadeClassifier('cascade_stop_sign.xml') cap = cv2.VideoCapture(0) while cap.isOpened(): _, img = cap.read() gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) stop_sign_scaled = stop_sign.detectMultiScale(gray, 1.3, 5) # Detect the stop sign, x,y = origin points, w = width, h = height for (x, y, w, h) in stop_sign_scaled: # Draw rectangle around the stop sign stop_sign_rectangle = cv2.rectangle(img, (x,y), (x+w, y+h), (0, 255, 0), 3) # Write "Stop sign" on the bottom of the rectangle stop_sign_text = cv2.putText(img=stop_sign_rectangle, text="Stop Sign", org=(x, y+h+30), fontFace=cv2.FONT_HERSHEY_SIMPLEX, fontScale=1, color=(0, 0, 255), thickness=2, lineType=cv2.LINE_4) cv2.imshow("img", img) key = cv2.waitKey(30) if key == ord('q'): cap.release() cv2.destroyAllWindows() break

dietherdave

have you tried
py

cv2.resizeWindow("Resized_Window", 300, 700)

dietherdave

just before imshow

dietherdave

py

import cv2
 
img = cv2.imread('/home/img/python.png', cv2.IMREAD_UNCHANGED)
 
print('Original Dimensions : ',img.shape)
 
scale_percent = 60 # percent of original size
width = int(img.shape[1]  scale_percent / 100)
height = int(img.shape[0]  scale_percent / 100)
dim = (width, height)
  
# resize image
resized = cv2.resize(img, dim, interpolation = cv2.INTER_AREA)
 
print('Resized Dimensions : ',resized.shape)
 
cv2.imshow("Resized image", resized)
cv2.waitKey(0)
cv2.destroyAllWindows()

You can also try this one. this just resizes an image but should work for a live feed

robertnotfound

solve it but the image is the same

robertnotfound

just some lines

robertnotfound

from raspberry camera 2

robertnotfound

v2