I'm using KineticJS to display images of a device similar to a webcam. To read the images I'm able to use a URL which return the JPG image. For testing purposes I have just added a event when the mouse cursor moves over the canvas. but updating the image fails. Only displaying the first one.
I think its a cache problem, but I'm not able to locate the problem.
Any help? Thanks in advance.
This is my JavaScript:
var stage;
var layer;
var dynamicImg;
stage = new Kinetic.Stage({
container: "container",
width: 640,
height: 480,
id: "myCanvas",
name: "myCanvas"
});
layer = new Kinetic.Layer();
//gets the canvas context
var canvas = stage.getContainer();
function drawImage(imageObj) {
dynamicImg = new Kinetic.Image({
image: imageObj,
x: 0,
y: 0,
width: 640,
height: 480,
draggable: false,
});
layer.add(dynamicImg);
stage.add(layer);
layer.draw();
};
var imageObj = new Image();
imageObj.onload = function () {
drawImage(this);
};
imageObj.src = 'http://<ip>/live.cgi';
stage.on('contentMousemove', function () {
imageObj = new Image();
imageObj.onload = function () {
layer.removeChildren();
drawImage(imageObj);
layer.draw();
};
imageObj.src = 'http://<ip>/live.cgi';
});