Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -448,6 +448,8 @@ def optimize(v, d):
|
|
448 |
mask = cv2.cvtColor(depth, cv2.COLOR_RGB2GRAY)
|
449 |
dcolor.append(bincount(frame[mask==0]))
|
450 |
print(dcolor[k])
|
|
|
|
|
451 |
|
452 |
#mask = cv2.convertScaleAbs(cv2.Laplacian(cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY), ddepth, ksize=kernel_size))
|
453 |
#mask[mask>0] = 255
|
@@ -588,54 +590,11 @@ async(f, c, o, b, p, d, n)=>{
|
|
588 |
|
589 |
on_click="""
|
590 |
async(p, d, n)=>{
|
591 |
-
function optimize() {
|
592 |
-
var options = new BABYLON.SceneOptimizerOptions(25);
|
593 |
-
var optimizer = new BABYLON.SceneOptimizer(BABYLON.Engine.LastCreatedScene, options);
|
594 |
-
optimizer.onSuccessObservable.add(function() {
|
595 |
-
alert('ok');
|
596 |
-
});
|
597 |
-
optimizer.onNewOptimizationAppliedObservable.add(function(optim) {
|
598 |
-
alert(optim.getDescription());
|
599 |
-
});
|
600 |
-
optimizer.onFailureObservable.add(function() {
|
601 |
-
alert('slow');
|
602 |
-
});
|
603 |
-
optimizer.start();
|
604 |
-
}
|
605 |
var intv = setInterval(function(){
|
606 |
-
try {
|
607 |
if (document.getElementById("iframe3D")===null || typeof document.getElementById("iframe3D")==="undefined") {
|
608 |
if (BABYLON && BABYLON.Engine.LastCreatedScene) {
|
609 |
BABYLON.Engine.LastCreatedScene.onAfterRenderObservable.add(function() { //onDataLoadedObservable
|
610 |
|
611 |
-
/*var then = new Date().getTime();
|
612 |
-
var now, delta;
|
613 |
-
const interval = 1000 / 25;
|
614 |
-
const tolerance = 0.1;
|
615 |
-
BABYLON.Engine.LastCreatedScene.getEngine().stopRenderLoop();
|
616 |
-
BABYLON.Engine.LastCreatedScene.getEngine().runRenderLoop(function() {
|
617 |
-
now = new Date().getTime();
|
618 |
-
delta = now - then;
|
619 |
-
then = now - (delta % interval);
|
620 |
-
if (delta >= interval - tolerance) {
|
621 |
-
BABYLON.Engine.LastCreatedScene.render();
|
622 |
-
}
|
623 |
-
});*/
|
624 |
-
|
625 |
-
let cameraChanged = false;
|
626 |
-
BABYLON.Engine.LastCreatedScene.activeCamera.onViewMatrixChangedObservable.add(camera => {
|
627 |
-
cameraChanged = true;
|
628 |
-
});
|
629 |
-
var renderLoop = function () {
|
630 |
-
BABYLON.Engine.LastCreatedScene.activeCamera.update();
|
631 |
-
if (cameraChanged) {
|
632 |
-
cameraChanged = false;
|
633 |
-
BABYLON.Engine.LastCreatedScene.render(false);
|
634 |
-
}
|
635 |
-
};
|
636 |
-
BABYLON.Engine.LastCreatedScene.getEngine().stopRenderLoop();
|
637 |
-
BABYLON.Engine.LastCreatedScene.getEngine().runRenderLoop(renderLoop);
|
638 |
-
|
639 |
var bg = JSON.parse(document.getElementById("bgcolor").getElementsByTagName("textarea")[0].value);
|
640 |
BABYLON.Engine.LastCreatedScene.getEngine().setHardwareScalingLevel(1.0);
|
641 |
for (var i=0; i<bg.length; i++) {
|
@@ -649,27 +608,8 @@ async(p, d, n)=>{
|
|
649 |
BABYLON.Engine.LastCreatedScene.getNodes()[i].material.pointSize = Math.ceil(Math.log2(Math.PI/document.getElementById("zoom").value));
|
650 |
}
|
651 |
}
|
652 |
-
/*var dome = new BABYLON.PhotoDome("dome", p[n].image.url,
|
653 |
-
{
|
654 |
-
resolution: 16,
|
655 |
-
size: 512
|
656 |
-
}, BABYLON.Engine.LastCreatedScene);
|
657 |
-
BABYLON.Engine.LastCreatedScene.getMeshByName("dome_mesh").applyDisplacementMap(d.background.url, 0, 255, null, null, null, true, function(e){alert(e);});
|
658 |
-
try {
|
659 |
-
for (i = 0; i < BABYLON.Engine.LastCreatedScene.getMeshByName("dome_mesh")._children.length; i++) {
|
660 |
-
var m = BABYLON.Engine.LastCreatedScene.getMeshByName("dome_mesh")._children[i];
|
661 |
-
m.dispose();
|
662 |
-
m = null;
|
663 |
-
}
|
664 |
-
for (i = 0; i < BABYLON.Engine.LastCreatedScene.getMeshByName("dome_mesh")._children.length; i++) {
|
665 |
-
var m = BABYLON.Engine.LastCreatedScene.getMeshByName("dome_mesh")._children[i];
|
666 |
-
alert(m.name);
|
667 |
-
BABYLON.Engine.LastCreatedScene.removeMesh(m);
|
668 |
-
}
|
669 |
-
} catch(e) {alert(e);}*/
|
670 |
BABYLON.Engine.LastCreatedScene.getAnimationRatio();
|
671 |
//BABYLON.Engine.LastCreatedScene.activeCamera.inertia = 0.0;
|
672 |
-
//BABYLON.Engine.LastCreatedScene.getMeshByName("dome_mesh").convertToUnIndexedMesh();
|
673 |
});
|
674 |
if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
|
675 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata = {
|
@@ -693,7 +633,6 @@ async(p, d, n)=>{
|
|
693 |
document.getElementById("model3D").getElementsByTagName("canvas")[0].remove();
|
694 |
clearInterval(intv);
|
695 |
}
|
696 |
-
} catch(e) {alert(e);}
|
697 |
}, 40);
|
698 |
}
|
699 |
"""
|
|
|
448 |
mask = cv2.cvtColor(depth, cv2.COLOR_RGB2GRAY)
|
449 |
dcolor.append(bincount(frame[mask==0]))
|
450 |
print(dcolor[k])
|
451 |
+
clrs = Image.fromarray(frame.astype(np.uint8)).convert('RGB').getcolors()
|
452 |
+
print(clrs)
|
453 |
|
454 |
#mask = cv2.convertScaleAbs(cv2.Laplacian(cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY), ddepth, ksize=kernel_size))
|
455 |
#mask[mask>0] = 255
|
|
|
590 |
|
591 |
on_click="""
|
592 |
async(p, d, n)=>{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
593 |
var intv = setInterval(function(){
|
|
|
594 |
if (document.getElementById("iframe3D")===null || typeof document.getElementById("iframe3D")==="undefined") {
|
595 |
if (BABYLON && BABYLON.Engine.LastCreatedScene) {
|
596 |
BABYLON.Engine.LastCreatedScene.onAfterRenderObservable.add(function() { //onDataLoadedObservable
|
597 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
598 |
var bg = JSON.parse(document.getElementById("bgcolor").getElementsByTagName("textarea")[0].value);
|
599 |
BABYLON.Engine.LastCreatedScene.getEngine().setHardwareScalingLevel(1.0);
|
600 |
for (var i=0; i<bg.length; i++) {
|
|
|
608 |
BABYLON.Engine.LastCreatedScene.getNodes()[i].material.pointSize = Math.ceil(Math.log2(Math.PI/document.getElementById("zoom").value));
|
609 |
}
|
610 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
611 |
BABYLON.Engine.LastCreatedScene.getAnimationRatio();
|
612 |
//BABYLON.Engine.LastCreatedScene.activeCamera.inertia = 0.0;
|
|
|
613 |
});
|
614 |
if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
|
615 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata = {
|
|
|
633 |
document.getElementById("model3D").getElementsByTagName("canvas")[0].remove();
|
634 |
clearInterval(intv);
|
635 |
}
|
|
|
636 |
}, 40);
|
637 |
}
|
638 |
"""
|