In HPCC Systems, pictures need to be uploaded to HPCC Systems before
they can be accessed. This blog post documents how to upload an image to
HPCC Systems
First upload the image to Landing Zones in ECL Watch:
After uploading, select this picture, and in Import, select BLOB:
Set up as follows:
Then use the following code to get the Hex content of this image:
1 2 3 4 5 6 7 8 9
imageRecord := RECORD STRING filename; DATA image; //first 4 bytes contain the length of the image data UNSIGNED8 RecPos{virtual(fileposition)}; END;
If you want to convert this Hex content into np array for subsequent
processing, you can use the following code:
1 2 3 4 5 6 7 8 9 10
STRING hexToNparry(DATA byte_array):= EMBED(Python) from PIL import Image import numpy as np import io bytes_data = bytes(byte_array) image = Image.open(io.BytesIO(bytes_data)) I_array = np.array(image) # this is all you need return ''.join(str(i) for i in I_array.shape) # check the shape of this image, height * width* channel ENDEMBED; OUTPUT(hexToNparry(imageData[1].image), NAMED('npShape'));