Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function read_rawimage_results(features) {
// ignore data for now and use results
// const compressed_data = results.responses[0].features[0].raw_image.compressed_data;
const compressed_data = features[0].raw_image.compressed_data;
const binary_compressed_data = base64ToUint8Array(compressed_data);
const jsonBuf = snappyjs.uncompress(binary_compressed_data);
var enc = new TextDecoder("utf-8");
const json = enc.decode(jsonBuf);
var imagedata = JSON.parse(json);
var width = results.responses[0].features[0].raw_image.width
var height = results.responses[0].features[0].raw_image.height
var img = new Image(width, height, imagedata, {kind: "RGB"})
var rgbaimg = img.rgba8();
return rgbaimg.toDataURL();
}
render() {
this.convertFloatMaskToImage();
var img = new Imagejs(this.instanceWidth, this.instanceHeight, this.maskImage, {kind: "RGB"})
var rgbaimg = img.rgba8();
var image = new window.Image();
image.src = rgbaimg.toDataURL();
console.log(rgbaimg.toDataURL());
var x1 = Math.round(this.props.instance_segment.xmin * this.imageWidth);
var x2 = Math.round(this.props.instance_segment.xmax * this.imageWidth);
var y1 = Math.round(this.props.instance_segment.ymin * this.imageHeight);
var y2 = Math.round(this.props.instance_segment.ymax * this.imageHeight);
return(
render() {
this.convertIntMaskToImage();
var img = new Imagejs(this.width, this.height, this.maskImage, {kind: "RGB"})
var rgbaimg = img.rgba8();
var image = new window.Image();
image.src = rgbaimg.toDataURL();
return(
<img height="{this.props.height}" width="{this.props.width}" y="{0}" x="{0}">
)
}
}