我正在尝试从图像中打印出内容。我已经将放置文本的像素归零,并且可以使用GRID_SIZE = 8
def placeQueen(row, columns):
if(row == GRID_SIZE):
print(columns) # it is where I print the positions
return [columns] # it is where I append the positions
results = []
for col in range(GRID_SIZE):
if(checkVlaid(row, col, columns)):
columns[row] = col
results += placeQueen(row+1, columns)
return results
def checkVlaid(row0, col0, columns):
for row in range(row0):
if(columns[row] == col0):
return False
if(abs(row - row0) == abs(columns[row] - col0)):
return False
return True
def Test():
columns = [-1]*GRID_SIZE
print placeQueen(0, columns) #the results are different from what I originally appended
Test()
突出显示它,但是我不确定如何打印出来。
cv2.rectangle