Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to make a new instance of Mat with TypedArray data?

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
 }});

how to make a new instance of Mat with TypedArray data?

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
 }});

updated)

somehow i can make Mat with Float32Array from worker but value is different like below. can i get a same data32F value in main.js?

image description

how to make a new instance of Mat with TypedArray data?

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
PlayingScreenCam.js( main thread )
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
 }});

updated)

somehow i can make Mat with Float32Array from worker but value is different like below. can i get a same data32F value in main.js?

image description

how to make a new instance of Mat with TypedArray data?

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
   console.log(p0.data32F);
   return self.postMessage({ result : p0.data32F, cols : p0.cols, rows : p0.rows }, [ p0.data32F.buffer ])
 }  catch (error) { return console.log('runGoodFeaturesToTrack error', error)}
}

// PlayingScreenCam.js( main thread )
this.dst = new window.cv.Mat();

 worker.addEventListener('message', ev => {
 if(ev.data.result) {
    const { result, cols, result, rows } = ev.data;
    const p0 = window.cv.matFromArray(rows, cols, window.cv.CV_32FC1, result.data32F) // error
result.data32F);
    console.log(p0.data32F);
 }});

updated)

somehow i can make Mat with Float32Array from worker but value is different like below. can i get a same data32F value in main.js?

image description

how to make a new instance of Mat with TypedArray data?

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
0.01 ]

   await cv.goodFeaturesToTrack(dst, p0, maxCorners, qualityLevel, minDistance, none,
   blockSize, false, 0.01);
   // p0.data32F : for point coordinates
   console.log(p0.data32F);
   return self.postMessage({ result : p0.data32F, cols : p0.cols, rows : p0.rows }, [ p0.data32F.buffer ])
 }  catch (error) { return console.log('runGoodFeaturesToTrack error', error)}
}

// PlayingScreenCam.js( main thread )
this.dst = new window.cv.Mat();

 worker.addEventListener('message', ev => {
 if(ev.data.result) {
    const { result, cols, rows } = ev.data;
    const p0 = window.cv.matFromArray(rows, cols, window.cv.CV_32FC1, result.data32F);
    console.log(p0.data32F);
 }});

updated)

somehow i can make Mat with Float32Array from worker but value is different like below. can i get a same data32F value in main.js?

image description