-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
101 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { decode as jpegDecode } from 'jpeg-js'; | ||
import { readFileSync } from 'node:fs'; | ||
import { dirname, join as joinPath } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { gunzipSync } from 'node:zlib'; | ||
|
||
export const _dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
||
function readRel(path, opts) { | ||
return readFileSync(joinPath(_dirname, path), opts); | ||
} | ||
|
||
export function json(path) { | ||
try { | ||
// Node.js | ||
return JSON.parse(readRel(path, { encoding: 'utf-8' })); | ||
} catch (error) { | ||
// Bundler | ||
const file = path.replace(/^\.\//, '').replace(/\.json$/, ''); | ||
if (path !== './' + file + '.json') throw new Error('Can not load non-json file'); | ||
// return require('./' + file + '.json'); // in this form so that bundler can glob this | ||
} | ||
} | ||
|
||
export function jsonGZ(path) { | ||
return JSON.parse(gunzipSync(readRel(path)).toString('utf8')); | ||
} | ||
|
||
const vectorPath = joinPath(_dirname, 'vectors', 'boofcv-v3'); | ||
export const DETECTION_PATH = joinPath(vectorPath, 'detection'); | ||
export function readJPEG(path) { | ||
console.log('readJPEG', vectorPath, path); | ||
return jpegDecode(readFileSync(joinPath(vectorPath, path))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters