hi,
I'm using goodFeaturesToTrack function in web worker for balancing workload.
after finishing goodFeaturesToTrack function, worker posts corners data.
I tried making new Mat with cv.matFromArray and its data(Float32Array), then it showed error like below:
RangeError: Source is too large “too large”
Is there any way to make a new Mat with TypedArray from worker? ( I found cv.matFromImageData(), but it use the cv.CV_8UC4 type. ) I want to make a new mat for detected corners and send it as argument for optical flow function
//worker.js
const runGoodFeaturesToTrack = async (imgData) => {
try {
// get imgData from main thread
const dst = await new cv.matFromArray(480, 640, cv.CV_8UC1, imgData)
const p0 = await new cv.Mat()
const none = await new cv.Mat()
const [ blockSize, maxCorners, minDistance, qualityLevel ] = [ 7, 10, 7.01, 0.01
await cv.goodFeaturesToTrack(dst, p0, maxCorners, qualityLevel, minDistance, none,
blockSize, false, 0.01);
// p0.data32F : for point coordinates
return self.postMessage({ result : p0.data32F, cols : p0.cols, rows : p0.rows }, [ p0.data32F.buffer ])
} catch (error) { return console.log('runGoodFeaturesToTrack error', error)}
}
// main.js
this.dst = new window.cv.Mat();
worker.addEventListener('message', ev => {
if(ev.data.result) {
const { cols, result, rows } = ev.data;
const p0 = window.cv.matFromArray(rows, cols, window.cv.CV_32FC1, result.data32F) // error
}});