Brauche Hilfe bei cv2-Fehler: (-209:Größen der Eingabeargumente stimmen nicht überein)Python

Python-Programme
Anonymous
 Brauche Hilfe bei cv2-Fehler: (-209:Größen der Eingabeargumente stimmen nicht überein)

Post by Anonymous »

Fehler: (-209:Größen der Eingabeargumente stimmen nicht überein) Die Operation ist weder „array op array“ (wobei Arrays dieselbe Größe und denselben Typ haben), noch „array op scalar“ oder „scalar op array“ in der Funktion „cv::binary_op“

Code: Select all

import cv2 as cv
import numpy as np

# Opens the image
image = cv.imread('numbers.jpg')
width = image.shape[1]
height = image.shape[0]

resized = cv.resize(image, (int(image.shape[1] * 0.5), int(image.shape[0] * 0.5)), interpolation=cv.INTER_LINEAR)
cropped_image = resized[int(width/9.6):int(width/4.8), int(height/4.32):int(height/(54/35))]
print(width, height)
cv.imshow('resized',cropped_image)

# Image processing
blank = np.zeros(image.shape, dtype='uint8')
gray = cv.cvtColor(cropped_image, cv.COLOR_BGR2GRAY)
ret, thresh = cv.threshold(gray, 120, 255,cv.THRESH_BINARY)
inverted_tresh = cv.bitwise_not(thresh)
cv.imshow('thresh', inverted_tresh)

# count white pixels
print(cv.countNonZero(inverted_tresh))
Dieser Code hat den Fehler verursacht und ich verstehe nicht warum:

Code: Select all

# Shape masking
masked_image = cv.bitwise_and(image, inverted_tresh)
cv.imshow('masked', masked_image)

cv.waitKey(0)

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post