I am accessing image data on Javascript. Now I'd like to pass this to Python process through Selenium API in the most efficient possible manner.
Passing canvas data is easy with canvas.toDataURL() method, but the downside is that the image is encoded and decoded to PNG, adding substantial overhead to the process.
I was just wondering if I could pass the raw array data from Javascript to Python via Selenium, so that
Either passing data in the native format (unsigned integer data)
Convert raw pixel data to base64 encoding, in some kind of toDataURL() manner or simply doing the processing yourself in Javascript (hopefully JIT'ed loop)
Looks like canvasContext.getImageData(0, 0, w, h).data object type is Uint8ClampedArray. What would be the best way to convert this data to some format which can be easily passed through Selenium to Python?
Selenium 2.0 RC, any Firefox version can be used.
Since your communication between Selenium and the browser through getEval is string based, I think that there is no escape from base64 encoding the image data. sending raw binary data will probably not be possible.
You can probably devise your own string encoding scheme, but it'll probably be as effective as the built in methods.
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