Skip to content

Commit

Permalink
feat: ok2
Browse files Browse the repository at this point in the history
  • Loading branch information
mussida committed Oct 24, 2024
1 parent ae9dd7c commit c51658d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
7 changes: 4 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"@angular/compiler": "^18.2.0",
"@angular/core": "^18.2.0",
"@angular/forms": "^18.2.0",
"@splidejs/splide": "^4.1.4",
"ngx-splide": "^7.0.1",
"@angular/platform-browser": "^18.2.0",
"@angular/platform-browser-dynamic": "^18.2.0",
"@angular/router": "^18.2.0",
"@splidejs/splide": "^4.1.4",
"ngx-splide": "^7.0.1",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.14.10"
Expand All @@ -29,6 +29,7 @@
"@angular/cli": "^18.2.2",
"@angular/compiler-cli": "^18.2.0",
"@types/jasmine": "~5.1.0",
"@types/node": "^22.7.9",
"autoprefixer": "^10.4.20",
"jasmine-core": "~5.2.0",
"karma": "~6.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
export class MotionDetectionComponent implements AfterViewInit, OnDestroy {
imageSpawned: boolean = false;
private localStream: MediaStream | null = null;
drawInterval: any;

constructor(private renderer: Renderer2) {}

Expand All @@ -23,11 +24,8 @@ export class MotionDetectionComponent implements AfterViewInit, OnDestroy {
}

ngOnDestroy(): void {
// Ferma il flusso video se il componente viene distrutto
if (this.localStream) {
const tracks = this.localStream.getTracks();
tracks.forEach((track) => track.stop());
this.localStream = null; // Libera il flusso
if (this.drawInterval) {
clearInterval(this.drawInterval);
}
}

Expand Down Expand Up @@ -153,7 +151,8 @@ export class MotionDetectionComponent implements AfterViewInit, OnDestroy {
localStream = stream;
camStream.srcObject = stream;
camStream.play();
setInterval(draw, 32);
this.drawInterval = setInterval(draw, 32);
this.drawInterval;
})
.catch((error) => console.error("Error accessing webcam:", error));
} else {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"compilerOptions": {
"outDir": "./dist/out-tsc",
"strict": true,
"types": ["node"],
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
Expand Down

0 comments on commit c51658d

Please sign in to comment.