Skip to content

Commit

Permalink
fix: カメラによる認識を開始する際のエラー
Browse files Browse the repository at this point in the history
  • Loading branch information
mugiply committed May 13, 2023
1 parent 0e0d974 commit 4eec4af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
15 changes: 7 additions & 8 deletions src/app/navi/services/scanner.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,34 @@ import { TileDatabaseService } from './tile-database.service';
providedIn: 'root',
})
export class ScannerService {
private classifier?: DonjaraTileScanner;
private classifier: DonjaraTileScanner = new DonjaraTileScanner();

constructor(private tileDatabaseService: TileDatabaseService) {}

async initialize() {
this.classifier = new DonjaraTileScanner({
await this.classifier.initialize({
modelBaseUrl: environment.modelBaseUrl,
});
await this.classifier.initialize();
}

public getCameraPreviewStream() {
return this.classifier!.getPreviewMediaStream();
return this.classifier.getPreviewMediaStream();
}

public get onScanned$() {
return this.classifier!.onScanned$;
return this.classifier.onScanned$;
}

public get onDetectionStatusChanged$() {
return this.classifier!.onDetectionStatusChanged$;
return this.classifier.onDetectionStatusChanged$;
}

async onVideoFrame(videoElement: HTMLVideoElement) {
await this.classifier!.onVideoFrame(videoElement);
await this.classifier.onVideoFrame(videoElement);
}

async detect() {
return this.classifier!.detect();
return this.classifier.detect();
}

async getCgTilesByScannerResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ export class DonjaraTileScanner {
// パイの表面領域の分類器
private tileClassifier!: TileClassifier;

constructor(params: { modelBaseUrl: string }) {
constructor() {}

async initialize(params: { modelBaseUrl: string }) {
if (this.previewCanvas) {
return;
}

this.tileDetector = new TileDetector({
modelBaseUrl: params.modelBaseUrl,
});
this.tileSurfaceExtractor = new TileSurfaceExtractor();
this.tileClassifier = new TileClassifier({
modelBaseUrl: params.modelBaseUrl,
});
}

async initialize() {
if (this.previewCanvas) {
return;
}

// プレビュー映像生成用キャンバスを初期化
this.previewCanvas = document.createElement('canvas');
Expand Down

0 comments on commit 4eec4af

Please sign in to comment.