Skip to content

Instantly share code, notes, and snippets.

View kalwalt's full-sized avatar
⛰️
Working on the mountains!

Walter Perdan kalwalt

⛰️
Working on the mountains!
View GitHub Profile
@kalwalt
kalwalt / FilterWasm-test.v3
Created April 23, 2024 17:07
test with Vector type instead of Array (Virgil)
def imgProc_gray(width: int, height: int, channels: u8, inputData: Pointer) -> Pointer {
var imgProc = ImgProc.new(width, height, channels);
var inputData_size = width * height * channels;
var internal_data: Vector<byte> = Vector<byte>.new();
for (i = 0; i < inputData_size; i++) {
internal_data[i] = (inputData + i).load<byte>();
}
return Pointer.atContents(imgProc.grayscale(internal_data));
}
@kalwalt
kalwalt / build.sh
Created April 15, 2024 22:00
simple example for virgil and wasm
// simple build script to compile the simple.v3 file to wasm
// it is required to have the virgil/bin and virgil/bin/dev in the PATH as described in the official documentation
// https://github.com/titzer/virgil
v3c -target=wasm simple.v3
docker exec emscripten-nft npm run build
> @webarkit/jsartoolkit-nft@1.6.1 build
> node tools/makem.js; echo Built at `date`
Warning: EMSCRIPTEN environment variable not found.
If you get a "command not found" error,
do `source <path to emsdk>/emsdk_env.sh` and try again.
@kalwalt
kalwalt / CMakeLists.txt
Last active September 23, 2023 23:10
Testing cmake config file for WebARKitLIb tests, it let you succesfully compile the tests with opencv-em
cmake_minimum_required(VERSION 3.24)
project(Webarkit_tests)
# GoogleTest requires at least C++14
set(CMAKE_CXX_STANDARD 14)
# Fetch googletest v1.13.0 commit b796f7d44681514f58a683a3a71ff17c94edb0c1
include(FetchContent)
FetchContent_Declare(
googletest
@kalwalt
kalwalt / log-02-04-2023-21:26.txt
Created April 2, 2023 19:27
log of passVideoData issue
artoolkitNFT_ES6_wasm.simd.js:1631 =================================================================
put_char @ artoolkitNFT_ES6_wasm.simd.js:1631
write @ artoolkitNFT_ES6_wasm.simd.js:1580
write @ artoolkitNFT_ES6_wasm.simd.js:3044
doWritev @ artoolkitNFT_ES6_wasm.simd.js:6253
_fd_write @ artoolkitNFT_ES6_wasm.simd.js:6266
$__sanitizer::internal_write(int, void const*, unsigned long) @ 003d3eaa:0xa490c
$__sanitizer::RawWrite(char const*) @ 003d3eaa:0xa1faa
$__sanitizer::SharedPrintfCode(bool, char const*, void*) @ 003d3eaa:0xa5ef7
$byn$mgfn-shared$__sanitizer::Printf(char const*, ...) @ 003d3eaa:0xab957
{GrayScaleMedia: ƒ, WebARKitController: ƒ}
WebARKitController.js:62 [WebARKitController] WebARKit initialized
WebARKitController.js:65 WebARKit 0.1.0
WebARKitController.js:106 <video id=​"video" autoplay muted playsinline>​</video>​
example.html:25 WebARKitController {jpegCount: 0, videoWidth: 1536, videoHeight: 178, listeners: {…}, instance: {…}, …}
example.html:28 GrayScaleMedia {_source: img#refIm, _width: 1637, _height: 2048, _canvas: canvas, _flipImageProg: 'attribute vec2 position;\nvarying vec2 tex_coords;\n…on = vec4(position * vec2(1, flipY), 0.0, 1.0);\n}', …}
example.html:30 Uint8Array(3352576) [31, 31, 30, 30, 30, 31, 32, 33, 35, 34, 32, 30, 29, 29, 30, 31, 35, 33, 30, 29, 30, 32, 33, 34, 29, 27, 26, 26, 28, 28, 27, 25, 28, 28, 28, 28, 27, 25, 24, 22, 25, 24, 23, 22, 22, 23, 24, 25, 23, 23, 22, 22, 21, 21, 20, 20, 22, 22, 22, 22, 22, 22, 22, 22, 19, 19, 19, 19, 19, 19, 19, 19, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 17, 17, 17, 16, 16, 15, 15, 15, 15, 15, 14, 14, 14, 14, …]
webark
webarkit_ES6_wasm.js:8 =================================================================
put_char @ webarwebarkit_ES6_wasm.js:8 =================================================================
put_char @ webarkit_ES6_wasm.js:8
write @ webarkit_ES6_wasm.js:8
write @ webarkit_ES6_wasm.js:8
doWritev @ webarkit_ES6_wasm.js:8
_fd_write @ webarkit_ES6_wasm.js:8
$__sanitizer::internal_write(int, void const*, unsigned long) @ 0101187e:0x2978d9
$__sanitizer::ReportFile::Write(char const*, unsigned long) @ 0101187e:0x29804e
$__sanitizer::RawWrite(char const*) @ 0101187e:0x294ace
const convertImageData = (
imageData: ImageData,
frame: any,
cv: any,
videoSize: any
) => {
if (!(frame instanceof cv.Mat)) {
throw new Error("Please input the valid cv.Mat instance.");
return;
}
@kalwalt
kalwalt / VideoCapture.ts
Created March 26, 2023 14:55
This .ts file is a mock of VideoCapture from Opencv.js, modified to fit my needs,
export function VideoCapture(videoSource: any) {
var video: any = null;
if (typeof videoSource === 'string') {
video = document.getElementById(videoSource);
} else {
video = videoSource;
}
if (!(video instanceof HTMLVideoElement)) {
throw new Error('Please input the valid video element or id.');
return;
@kalwalt
kalwalt / WebARKitCV.test.ts
Created March 25, 2023 18:12
Failing jest test for WebARKitCV class.
/**
* @jest-environment jsdom
*/
import {describe, expect, test} from '@jest/globals';
import { WebARKitCV } from '../src/WebARKitCV';
describe('Init WebARKitCV and test the properties', () => {
test('Init the constructor...', () => {