Created
March 26, 2023 15:00
-
-
Save kalwalt/fc9a57d55a8897cc154dcf06f5018254 to your computer and use it in GitHub Desktop.
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
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; | |
} | |
if (frame.type() !== cv.CV_8UC4) { | |
throw new Error("Bad type of input mat: the type should be cv.CV_8UC4."); | |
return; | |
} | |
if (frame.cols !== videoSize.width || frame.rows !== videoSize.height) { | |
throw new Error( | |
"Bad size of input mat: the size should be same as the video." | |
); | |
return; | |
} | |
console.log(imageData); | |
return frame.data.set(imageData.data); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment