EmguCV tests on img: C:\Dump\PrismData\PrismSample1.jpg Image Size: Width=512, Height=512 ######################################################################## Tests reading a 3 byte pixel from a Mat() ######################################################################## access via recommended conversion to Image and then fast Image<> access single call to: matImage.ToImage(); then 3x pixelValue[?] = bgrImage.Bytes[?]; Iterations: 1000, Execution Time: 262 ms, Operations/Sec: 3816 access via recommended conversion to Matrix and then direct Matrix access appears to be buggy, skipped Iterations: 1000, Execution Time: 0 ms, Operations/Sec: 0 copy via Interop Marshal.Copy using pointers single call to: Marshal.Copy(matImage.DataPointer, pixelValue, 0, 3); Iterations: 1000000, Execution Time: 20 ms, Operations/Sec: 50000000 NOTE: this technique cannot be trusted - seems to corrupt memory occasionally on larger copies ######################################################################## Tests reading a 3 byte pixel from an Image ######################################################################## recommended access via Image[,] single call to: outBGR = bgrImage[row, col]; Iterations: 1000000, Execution Time: 79 ms, Operations/Sec: 12658227 access via the Image<>.bytes[] sequence of three: pixelValue[?] = bgrImage.Bytes[?]; Iterations: 1000, Execution Time: 837 ms, Operations/Sec: 1194 direct access via Image<>.Data[,,] sequence of three: pixelValue[?] = bgrImage.Data[row, col, ?]; Iterations: 1000000, Execution Time: 11 ms, Operations/Sec: 90909090 array copy via Array.Copy() single call to: Array.Copy(bgrImage.Data, 0, arrayValue, 0, 3); Iterations: 1000000, Execution Time: 17 ms, Operations/Sec: 58823529 array copy via Array.Copy() single call to: Marshal.Copy(bgrImage.Ptr, pixelValue, 0, 3);; Iterations: 1000000, Execution Time: 11 ms, Operations/Sec: 90909090 NOTE: this technique cannot be trusted - seems to corrupt memory occasionally on larger copies ######################################################################## Tests setting Image<> and Mat() to a solid color ######################################################################## Set Cv8U Mat to Solid Color single call to: testMatCv8U.SetTo(SCALAR_RED) Iterations: 1000, Execution Time: 24 ms, Operations/Sec: 41666 Set Cv32S Mat to Solid Color single call to: testMatCv32S.SetTo(SCALAR_RED) Iterations: 1000, Execution Time: 95 ms, Operations/Sec: 10526 Set 8 bit Image<> to Solid Color single call to: testImageByte.SetValue(SCALAR_RED) Iterations: 1000, Execution Time: 23 ms, Operations/Sec: 43478 Set 32 bit Image<> to Solid Color single call to: testImageInt32.SetValue(SCALAR_RED) Iterations: 1000, Execution Time: 95 ms, Operations/Sec: 10526 ######################################################################## Tests converting Image<> and Mat() from one format to another ######################################################################## convert Mat from Bgr to Bgr2Gray single call to: CvInvoke.CvtColor(matImage, matImage, ColorConversion.Bgr2Gray); Iterations: 1000, Execution Time: 86 ms, Operations/Sec: 11627 convert Image from Bgr to Bgr2Gray single call to: CvInvoke.CvtColor(bgrImage, grayImageDummy, ColorConversion.Bgr2Gray); Iterations: 1000, Execution Time: 82 ms, Operations/Sec: 12195 convert Mat from Bgr to YUV single call to: CvInvoke.CvtColor(matImage, yuvMatDummy, ColorConversion.Bgr2Yuv Iterations: 1000, Execution Time: 155 ms, Operations/Sec: 6451 NOTE: the colors do not seem to translate correctly in this conversion convert Image from Bgr to YUV single call to: CvInvoke.CvtColor(bgrImage, yccImageDummy, ColorConversion.Bgr2Yuv); Iterations: 1000, Execution Time: 151 ms, Operations/Sec: 6622 NOTE: the colors do not seem to translate correctly in this conversion ######################################################################## Tests getting an array of data from Image<> and Mat() ######################################################################## Get 8 bit Byte[] from Mat() via RawData() single call to: byteArray = matImage.GetRawData(); Iterations: 1000, Execution Time: 254 ms, Operations/Sec: 3937 Get 8 bit Byte[] from Image<> via Bytes single call to: byteArray = bgrImage.Bytes; Iterations: 1000, Execution Time: 251 ms, Operations/Sec: 3984 ######################################################################## Tests loading Image<> and Mat() from arrays ######################################################################## Populate 8 bit Image from Byte[,,] Via Array Copy single call to: Array.Copy(dataArray, 0, imgDummy.Data, 0, (bgrImage.Height * bgrImage.Width * bgrImage.NumberOfChannels)); Iterations: 1000, Execution Time: 26 ms, Operations/Sec: 38461 Populate 8 bit Image from Byte[] Via Pinned Memory Setup Pinned Memory and single call to: imgDummy = new Image(matImage.Height, matImage.Width, 0, ptr); Iterations: 1000000, Execution Time: 1803 ms, Operations/Sec: 554631 NOTE: includes the time to setup the Pinned Memory Populate 8 bit Mat() from Byte[] Via Pinned Memory single call to: testMat4 = new Mat(matImage.Height, matImage.Width, DepthType.Cv8U, 3, pointer, 0); Iterations: 1000000, Execution Time: 303 ms, Operations/Sec: 3300330 NOTE: does not include the time to setup the Pinned Memory Populate 8 bit Mat() from Byte[] Via Pinned Memory Setup pinned memory and single call to: testMat4 = new Mat(matImage.Height, matImage.Width, DepthType.Cv8U, 3, pointer, 0); Iterations: 1000000, Execution Time: 480 ms, Operations/Sec: 2083333 NOTE: includes the time to setup the Pinned Memory