Reputation: 1216
I created a code in which, when "load" is clicked, the user will upload a .png image and opencv will perform houghcircle and count the circles.
and the count, will be displayed on the textlabel. The circles.shape would result to (1, 99, 3), and I want to display 99, or even the whole (1, 99, 3) on the textlabel.
the problem is, I get this error after uploading the image
Traceback (most recent call last): File "try.py", line 58, in Browse self.label_2.setText(circles.shape) TypeError: setText(self, str): argument 1 has unexpected type 'tuple'
Here is my code:
def Browse(self):
filter = "Images (*.png)"
fname, _ = QFileDialog.getOpenFileName(self, "Open Image", "Desktop", filter)
print(fname)
self.scene = QGraphicsScene()
self.scene.addPixmap(QPixmap(fname))
self.graphicsView_2.setScene(self.scene)
img = cv2.imread(fname,0)
cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)
circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,5,
param1=200,param2=8,minRadius=0,maxRadius=7)
circles = np.uint16(np.around(circles))
for i in circles[0,:]:
# draw the outer circle
cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),1)
# draw the center of the circle
cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),1)
numberofcells = print(circles.shape)
self.label_2.setText(circles.shape)
any help would be appreciated. Thank you so much!
Upvotes: 0
Views: 20388