Created
October 26, 2018 17:38
-
-
Save olokobayusuf/0c25f0cc086cc3dec7d958bed0d44ff2 to your computer and use it in GitHub Desktop.
A script illustrating the recommended NatCam-OpenCV workflow.
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
byte[] pixelBuffer; | |
Mat previewMatrix; | |
void Start () { | |
// Start the camera preview | |
NatCam.Play(DeviceCamera.RearCamera); | |
// Register for preview events | |
NatCam.OnStart += OnStart; | |
NatCam.OnFrame += OnFrame; | |
} | |
void OnStart () { | |
// Display preview on a RawImage or plane? | |
... | |
// Initialize the preview buffer and matrix | |
pixelBuffer = new byte[NatCam.Preview.width * NatCam.Preview.height * 4]; | |
previewMatrix = new Mat(NatCam.Preview.height, NatCam.Preview.width, CvType.CV_8UC4); | |
} | |
void OnFrame () { | |
// Update the preview data with the current preview frame | |
NatCam.CaptureFrame(pixelBuffer); | |
Utils.copyToMat (pixelBuffer, previewMatrix); | |
// Do OpenCV stuff | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment