How can I load a yml file in Python and work with it ?
I used :
import cv
data = cv.Load("Z:/data/xyz_00000_300.yml")
But when I print data, it just gives the detail of the image like number of rows and columns etc.
I want to read what is there in the pixel of the image.
I tried to use the following code, but it gives me only the pixel values not the information contained in pixel?
def AccessPixels(img):
for y in range(0, img.height):
for x in range(0, img.width):
cv.Get2D(img, y, x) # Slow get pixel value.
cv.Set2D(img, y, x, (0, 0, 0, 0)) # Slow set pixel value.
To load and interact with yml files you need to first:
import yaml
Now you can read in a yaml file as a dictionary by doing something like this:
with codecs.open('your.yml', 'r', encoding='utf8') as f:
yml_dict = yaml.safe_load(f)
Now the contents of the yaml file are available to you as a dictionary within yml_dict.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With