diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cde7f5a8..1ce2f5253 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1221,16 +1221,14 @@ ELSEIF (WIN32) "${INSTALL_DEBUGER_VISUALIZER_COMMAND} ExecDos::exec /NOUNLOAD /TOSTACK '\\\$INSTDIR\\\\miscellaneous\\\\vswhere.exe -version [16.0,17.0) -property installationPath' '' '$EXEDIR\\\\execdos.log' Pop $0 - StrCmp $0 0 0 Find_VS_Failed + StrCmp $0 0 0 Find_VS_Install_Failed Pop $1 StrCpy $${vs_version}_INSTALL_FOLDER '\\\$1\\\\Common7\\\\Packages\\\\Debugger\\\\Visualizers\\\\' - goto Find_VS_Success - Find_VS_Failed: - MessageBox MB_OK 'Failed to find VS2019' - goto Find_VS_End - Find_VS_Success: - MessageBox MB_OK 'Found VS2019: $1' - Find_VS_End: + goto Find_VS_Install_Success + Find_VS_Install_Failed: + goto Find_VS_Install_End + Find_VS_Install_Success: + Find_VS_Install_End: ") ELSE() SET(INSTALL_DEBUGER_VISUALIZER_COMMAND diff --git a/Emgu.CV.Example/RealtimeCamera.UWP/MainPage.xaml.cs b/Emgu.CV.Example/RealtimeCamera.UWP/MainPage.xaml.cs index cc4157d3f..385f64835 100644 --- a/Emgu.CV.Example/RealtimeCamera.UWP/MainPage.xaml.cs +++ b/Emgu.CV.Example/RealtimeCamera.UWP/MainPage.xaml.cs @@ -51,9 +51,10 @@ namespace RealtimeCamera private Matrix mapx, mapy; private VideoCapture _capture; + public void Process() { - Mat m = new Mat(); + Mat m = new Mat(new System.Drawing.Size(640, 480), DepthType.Cv8U, 3); Mat mProcessed = new Mat(); while (true) { @@ -62,17 +63,7 @@ namespace RealtimeCamera { try { - if (_capture == null) - { - _capture = new VideoCapture(); - if (!_capture.IsOpened) - { - //Stop the capture - captureButton_Click(this, null); - continue; - } - - } + //Read the camera data to the mat //Must use VideoCapture.Read function for UWP to read image from capture. @@ -95,15 +86,15 @@ namespace RealtimeCamera int centerY = m.Width >> 1; int centerX = m.Height >> 1; //CvInvoke.SetIdentity(_cameraMatrix, new MCvScalar(1.0)); - _cameraMatrix.SetTo(new double[] + _cameraMatrix.SetTo(new float[] { - 1, 0, centerY, - 0, 1, centerX, - 0, 0, 1 + 1f, 0f, (float)centerY, + 0f, 1f, (float)centerX, + 0f, 0f, 1f }); _distCoeffs = new Mat(new System.Drawing.Size(5, 1), DepthType.Cv32F, 1); - _distCoeffs.SetTo(new double[] { -0.000003, 0, 0, 0, 0 }); + _distCoeffs.SetTo(new float[] { -0.000003f, 0f, 0f, 0f, 0f }); mapx = new Matrix(m.Height, m.Width); mapy = new Matrix(m.Height, m.Width); CvInvoke.InitUndistortRectifyMap( @@ -181,6 +172,17 @@ namespace RealtimeCamera if (_captureEnabled) { + if (_capture == null) + { + _capture = new VideoCapture(); + if (!_capture.IsOpened) + { + //Stop the capture + captureButton_Click(this, null); + _captureEnabled = !_captureEnabled; + return; + } + } captureButton.Content = "Stop"; } else diff --git a/Emgu.CV/Core/Mat.cs b/Emgu.CV/Core/Mat.cs index 73b7038a8..6c6942699 100644 --- a/Emgu.CV/Core/Mat.cs +++ b/Emgu.CV/Core/Mat.cs @@ -137,7 +137,8 @@ namespace Emgu.CV /// The managed array where data will be copied from public void SetTo(T[] data) { - Debug.Assert(data.Length == Total.ToInt32() * ElementSize / Toolbox.SizeOf(), String.Format("Invalid data length, expecting {0} but was {1}", Total.ToInt32() * ElementSize / Toolbox.SizeOf(), data.Length)); + Debug.Assert(data.Length == Total.ToInt32() * ElementSize / Toolbox.SizeOf(), String.Format("Invalid data length, expecting array of size {0} but got array of size {1}", Total.ToInt32() * ElementSize / Toolbox.SizeOf(), data.Length)); + //Debug.Assert(CvInvoke.GetDepthType(typeof(T)) == this.Depth, String.Format("Array type {0} do not match Mat data type {1}.", typeof(T), this.Depth)); GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned); MatInvoke.cveMatCopyDataFrom(this, handle.AddrOfPinnedObject()); handle.Free();