Ask Your Question
1

python code in tutorial "file input and output using xml and yaml files"

asked 2020-04-09 00:06:46 -0600

xxxlucodes gravatar image

updated 2020-04-09 02:45:52 -0600

berak gravatar image

Hello, I am new to openCV. I'm following the tutorials "File Input and Output using XML and YAML files ".

I encountered a problem when i execute the python code there. I cannot get the same result as the tutorial,

########################################################
Traceback (most recent call last):
  File "file_input_output.py", line 156, in <module>
    main(sys.argv)
  File "file_input_output.py", line 78, in main
    s.write('image1.jpg','Awesomeness')
cv2.error: OpenCV(4.3.0-pre) /home/ehuman/working_cv/opencv-master/modules/core/src/persistence_yml.cpp:251: error: (-5:Bad argument) Key names may only contain alphanumeric characters [a-zA-Z0-9], '-', '_' and ' ' in function 'writeScalar'
############################################################

It seems that the python binding here does not work well, could anybody help me explain the reason?

edit retag flag offensive close merge delete

Comments

I cannot get the same result as the tutorial,

i doubt, that this was ever tested properly (from python)

berak gravatar imageberak ( 2020-04-09 04:52:16 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2020-04-09 04:47:13 -0600

berak gravatar image

updated 2020-04-09 04:48:51 -0600

you found a bug in the python wrappers / tutorial.

while it is possible to write single strings / scalars from c++, you can only write key-value pairs from python , with the restriction, that the keys may not contain certain characters, like . dots or / slashes even.

so, the (python) tutorial code does not work properly.

for now, just comment those lines:

#s.write('strings', '[')
#s.write('image1.jpg','Awesomeness')
#s.write('../data/baboon.jpg',']')

then please raise an issue here with your findings, and we'll see, what can be done about it

edit flag offensive delete link more

Comments

thank you very much, I will raise this usse there

xxxlucodes gravatar imagexxxlucodes ( 2020-04-12 21:17:04 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-04-09 00:06:46 -0600

Seen: 336 times

Last updated: Apr 09 '20