void Update() { this.transform.Rotate(Vector3.up, RotateSpeed * Time.deltaTime); if (wct.width > 100 && wct.height > 100) { Color32[] pixels = wct.GetPixels32(); GCHandle pixelHandle = GCHandle.Alloc(pixels, GCHandleType.Pinned); IntPtr results = NativeLibAdapter.SubmitFrame(wct.width, wct.height, pixelHandle.AddrOfPinnedObject()); int bufferSize = wct.width * wct.height * 4; byte[] rawData = new byte[bufferSize]; if (results != IntPtr.Zero) { Marshal.Copy(results, rawData, 0, bufferSize); outTexture.LoadRawTextureData(rawData); outTexture.Apply(); } InImage.texture = wct; OutImage.texture = outTexture; rawData = null; pixelHandle.Free(); } }
void Awake() { #if UNITY_EDITOR int width = 1280; int height = 720; #else int width = 320; int height = 240; #endif NativeLibAdapter.InitCV(width, height); outTexture = new Texture2D(width, height, TextureFormat.RGBA32, false); wct = new WebCamTexture(width, height); wct.Play(); Debug.LogWarning("Foo Value in C++ is " + NativeLibAdapter.FooTest()); }
void Start() { // Save a black and white image NativeLibAdapter.SaveBlackAndWhite(m_ImagePath); // Detect edges and outer hull NativeLibAdapter.DetectOuterHull(m_ImagePath); // Compare image similarity by comparing shapes float similarity = NativeLibAdapter.GetImageStructureSimilarity(m_ImagePath, m_ImageToCompare); Debug.Log("Similarity from structure : " + similarity); // Compare image similarity by comparing feature points NativeLibAdapter.GetImageSiftSimilarity(m_TestSiftMarker, m_TestSiftCompare); // Crop and rotate image NativeLibAdapter.TransformImage(m_ImagePath, 90f, 0.5f, 100, 100); }