Ask Your Question
0

how to print what is there is in a variable to the frame.

asked 2019-04-16 09:36:12 -0600

ravikanth076@gmail.com gravatar image

updated 2019-04-16 10:38:38 -0600

hi.

please help me. Im doing a project. In that project i will be getting response from the server. I want to print this response on the frame. I tried putting the response object in cv2.putText().

like this.

cv2.putText(frame, response , (0,50), cv2.FONT_HERSHEY_SIMPLEX, 2, (0,0,255), 3, cv2.LINE_AA)

but this statement is giving me the error.

error:

cv2.putText(frame, response , (0,50), cv2.FONT_HERSHEY_SIMPLEX, 2, (0,0,255), 3, cv2.LINE_AA)

TypeError: bad argument type for built-in operation

I googled the function to print what is there in the response. But I didn't get any function.

so pleae help me to solve this.

edit retag flag offensive close merge delete

Comments

1

" this statement is giving me the error." Must we guess this error?

cv2.putText(frame response , (0,50), cv2.FONT_HERSHEY_SIMPLEX, 2, (0,0,255), 3, cv2.LINE_AA)

Why do you add a space bteween frame and response?

LBerger gravatar imageLBerger ( 2019-04-16 09:39:26 -0600 )edit

sorry I forgot to put the comma in between them. but even after putting the comma in between frame and response also im getting the error.

ravikanth076@gmail.com gravatar image[email protected] ( 2019-04-16 09:46:18 -0600 )edit

" also im getting the error." Must we guess this error? add error message as text in your post : use edit button

LBerger gravatar imageLBerger ( 2019-04-16 10:10:30 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2019-04-16 11:11:54 -0600

LBerger gravatar image

updated 2019-04-16 11:12:56 -0600

Check argument type : this program is good

img = np.zeros((256,256,3),np.uint8)
 x = cv.putText(img,'test',(100,10), cv.FONT_HERSHEY_SIMPLEX, 1.0,(255,255,255),lineType=cv.LINE_AA)

but this is wrong :

x = cv.putText(img,['test'],(100,10), cv.FONT_HERSHEY_SIMPLEX, 1.0,(255,255,255),lineType=cv.LINE_AA)
 File "<stdin>", line 1, in <module>
TypeError: bad argument type for built-in operation

or this one

 x = cv.putText(img,49,(100,10), cv.FONT_HERSHEY_SIMPLEX, 1.0,(255,255,255),lineType=cv.LINE_AA)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: bad argument type for built-in operation
edit flag offensive delete link more

Comments

img = np.zeros((256,256,3),np.uint8)

x = cv.putText(img,'test',(100,10), cv.FONT_HERSHEY_SIMPLEX, 1.0,

(255,255,255),lineType=cv.LINE_AA)

in the above code test is just a text. It is not a variable. If I pass the text, Im not getting error. But when im

passing the variable then only im getting error. so please help me. and also please tell me why you declared

the img variable.?. i did'nt understood. as im new new to opencv please tell me sir.

ravikanth076@gmail.com gravatar image[email protected] ( 2019-04-16 11:24:17 -0600 )edit
1

I don't understand :

s = 'text'
x = cv.putText(img,s,(100,10), cv.FONT_HERSHEY_SIMPLEX, 1.0,(255,255,255),lineType=cv.LINE_AA)

and check type(response)

LBerger gravatar imageLBerger ( 2019-04-16 11:27:26 -0600 )edit
0

answered 2019-04-16 21:27:25 -0600

supra56 gravatar image

What's server url locators ..... response = url? Try this:

import cv2 as cv
import numpy as np

img = np.zeros((256,256,3),np.uint8)
response= 'opencv.org'

cv.putText(img, response,(0, 50),
               cv.FONT_HERSHEY_SIMPLEX,
               3,(0, 0, 255),
               lineType=cv.LINE_AA)

cv.imshow('frame', img)
cv.waitKey(0)
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-04-16 09:36:12 -0600

Seen: 6,131 times

Last updated: Apr 16 '19