Feature node libs#140
Conversation
|
The new loadCamera function now can run without errors but i don't receive a message like: jsartoolkitNFT/emscripten/ARToolKitJS.cpp Lines 704 to 741 in 251de77 setCamera: jsartoolkitNFT/emscripten/ARToolKitJS.cpp Lines 413 to 456 in 251de77 It could depends by the type of printings, maybe stream by ARLOGw is not outputted in node? |
|
i make a simple test, i added a simple std::cout message before: if (arc->param.xsize != arc->width || arc->param.ysize != arc->height) {
ARLOGw("*** Camera Parameter resized from %d, %d. ***\n", arc->param.xsize, arc->param.ysize);
arParamChangeSize(&(arc->param), arc->width, arc->height, &(arc->param));
}and i get the message in the console, so i assume that for some reason simply the camera is not resized. |
- only basic methods
|
Testing new node listeners, but actually the code (see node/example.js) can't detect and track the pinball image. If the data passed to the process function it should print that the nft marker is tracked, Instead i got a NftMarkerInfo struct with a not found marker. When i have a bit of time i will try to debug why is not detecting. |
|
In regards of the previous comment: this could be caused because artoolkitNFT.NFTMarkerInfo Is not attached to the |
|
I improved the code with a new dist dile specyfic for node, i added two new wxamples but still they can't detect the marker. Initially i thought that i was supplying the imnage data in a wrong way, but i'm not sure of this anymore. There is some bug somewhere in the code, maybe i can add some more debug printings in the C++ code? |
…s for improved ID handling
process() expects RGBA pixel data, so decode with sharp's ensureAlpha() instead of RGB/JPEG bytes, and run process() after the marker loads in a short loop so NFT tracking can lock on. Clean up the examples and add the pinball-demo.jpg test image they depend on. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Restore the IDE config, build artifact, and python-bindings ignore rules that are present on master but missing from this branch. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Align example_canvas.js with the other node examples: same test image and controller dimensions. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
# Conflicts: # build/artoolkitNFT.debug.js # build/artoolkitNFT.min.js # build/artoolkitNFT_embed_ES6_wasm.js # build/artoolkitNFT_wasm.js # build/artoolkitNFT_wasm.simd.js # dist/ARToolkitNFT.js # dist/ARToolkitNFT_simd.js # dist/ARToolkitNFT_td.js # emscripten/ARToolKitJS.cpp # package-lock.json # package.json # src/Utils.ts # tools/makem.js # types/src/Utils.d.ts # webpack.config.js
Add "types": ["node"] so the node sources (which use require) type-check; without it ts-loader fails with TS2591. Rebuild the node wasm and dist bundle from the merged source via docker + webpack, and regenerate the lockfile to include canvas/sharp. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Finally with commit 409b7da the examples detect the nft pinball marker, it's a great result! |
Delete the obsolete pinball-test images (no longer referenced by any example) and ignore emscripten/zlib/build. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The node bundle is Node-only, so commonjs2 is leaner and more idiomatic than umd (drops the dead AMD/global-object branches). Consumption is unchanged: require() and default import still work. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Node now resolves require('@webarkit/jsartoolkit-nft') to the node build
while browsers/bundlers get the UMD build. Adds named subpaths /simd, /td,
/node, keeps the ./dist/* wildcard so existing deep-imports (and script
tags / importScripts, which bypass exports) keep working.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Explain per-environment resolution (browser UMD vs Node build), the /simd, /td, /node subpaths, and that script/importScripts URLs are unaffected. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
node-src was an earlier no-webpack node implementation that directly required build/artoolkitNFT_node_wasm.js. The TypeScript sources (src/*_node.ts -> dist/ARToolkitNFT_node.js) are the canonical node path wired into the package exports, so drop the duplicate node-src and the example.js that used it (example_dist.js covers the same flow via dist). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add a Node.js (experimental) section mirroring the Python bindings one:
marks it experimental, shows require('@webarkit/jsartoolkit-nft') usage
with a small sharp-based example, lists what works / is not yet done, and
points to examples/node (example_dist.js, example_canvas.js).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Remove the per-frame debug dumps (sourceImage, videoSize, videoluma, nftMarkerInfo) from the node controller's process loop, which flooded the console with multi-million-element typed arrays. Also fix dispatchEvent to notify EventEmitter listeners registered via on() (it only called the separate addEventListener registry before), so the examples' getNFTMarker handler actually fires. Examples now log the concise marker data instead of the whole event (which carried the controller + its buffers). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
jsartoolkitNFT in a Node.js environment
Continues from #128 / #129. Adds an experimental Node.js build of jsartoolkitNFT so NFT marker detection can run server-side (no browser, camera or
<canvas>), driven by static image data. Files are loaded through emscripten NODEFS (FORCE_FILESYSTEM + NODEFS/FS), which is the main difference from the browser build.What's in this PR
Node library
src/ARControllerNFT_node.ts,src/ARToolkitNFT_node.ts,src/index_node.ts,src/factoryFunctions/initARToolkitNFT_node.ts,src/abstractions/IARToolkitNFT_node.ts(+ generatedtypes/).tools/makem.js: newcompile_wasm_nodetarget →build/artoolkitNFT_node_wasm.js(emscripten withENVIRONMENT=node,FORCE_FILESYSTEM,NODEFS/FS,-lnodefs.js).webpack.config.js: newnodetarget (target: "node") → self-containeddist/ARToolkitNFT_node.js, emitted ascommonjs2(leaner than UMD for a Node-only artifact).Package consumption
exportsmap:require('@webarkit/jsartoolkit-nft')resolves to the Node build in Node and the UMD build in browsers/bundlers./simd,/td,/node, plus a./dist/*wildcard so existing deep-imports keep working.<script>/importScripts/ CDN URLs are unaffected byexports.Examples (
examples/node/)example_dist.js— sharp + the Node build (also wired asnpm run test-node-example).example_canvas.js— thecanvaspackage,requestAnimationFrameloop.pinballNFT dataset,camera_para.dat, andpinball-demo.jpg.Fixes & cleanup
process()expects RGBA pixel data (sharp().ensureAlpha().raw()), and must run after the marker loads (tracking needs several iterations to lock on).getNFTMarker:dispatchEvent()now also notifiesEventEmitterlisteners registered viaon()(previouslyon()anddispatchEvent()used two disconnected registries, so the event never fired).process()loop; examples now log the concise marker data.node-src/(an earlier no-webpack attempt) in favor of the canonical TS →distpath.Maintenance
masterinto the branch (it was well behind) and rebuilt the libs; synced.gitignore; removed unusedpinball-test*images.exportsmap / subpaths.Usage
Verification
npm run build-docker(emscripten) rebuilds all wasm targets incl.artoolkitNFT_node_wasm.js.npm run build-ts(webpack) rebuilds dist for all 4 targets (default / simd / td / node).examples/node/example_dist.jsandexample_canvas.jsdetect thepinballmarker.Tasks
Follow-ups (separate PRs)
output.library.type: "module") so namedimport { ... }works — currently CommonJS, so userequire()/ defaultimport.