agentscript0 icon indicating copy to clipboard operation
agentscript0 copied to clipboard

Initialize a model with an image?

Open bennlich opened this issue 11 years ago • 1 comments

I think I remember you talking about this, but I'm not sure if it's implemented yet? Initializing a model (and its size) from a loaded image? Could you do something like

DataSet.importImageDataSet('my-image', function(dataset) {
    new Model('div', 1, dataset.width, 1, dataset.height, 1);
})

?

bennlich avatar Feb 03 '14 19:02 bennlich

Woops, sorry to be late responding.

I usually do the image import outside creating the model, just like you show. u.importImage flags.imageName, (img)=> w = flags.scaleWidth; h = Math.round img.height*w/img.width model = new MyModel("layers", 1, 1,w, 1,h, false, false) .debug() # Debug: Put Model vars in global name space .start() # Run model immediately after startup initialization

The flags object is the REST initialization parameters, here the image name and scale.

Note that the image is cached inside agentscript's "file index" so any second use of u.importImage is sync.

-- Owen

backspaces avatar Mar 11 '14 16:03 backspaces