I have a image i need to read the black color of image and change the black to some text using unity
I am working on project where i am getting the webcam texture and clicking the photo and converting the image to black and white using threshold. I want the black area to be filled with text like the image below :
The code below shows how I am capturing the image and using the threshold value to have the black and white effect. The last lines are used to save the captured image on the disk.
Texture2D photo = new Texture2D(webCamTexture.width , webCamTexture.height);
photo.SetPixels(webCamTexture.GetPixels());
photo.Apply();
Mat imgMat = new Mat(photo.height, photo.width, CvType.CV_8UC1);
Utils.texture2DToMat(photo, imgMat);
Debug.Log("imgMat.ToString() " + imgMat.ToString());
Imgproc.threshold(imgMat, imgMat, 100 , 200, Imgproc.THRESH_BINARY | Imgproc.THRESH_OTSU);
Texture2D texture = new Texture2D(imgMat.cols(), imgMat.rows(), TextureFormat.RGBA32, false);
Utils.matToTexture2D(imgMat, texture);
byte[] bytes = texture.EncodeToJPG();
File.WriteAllBytes(path + _CaptureCounter.ToString() + ".jpg", bytes);
Here is the current result with the above code:
Thank you in advance for your help
Your answer
Follow this Question
Related Questions
Image Effects keep on rendering 0 Answers
how would i change the colour of an image once I've hovered over a button? 0 Answers
CRT Shader how optimize?! 1 Answer
Why does my Image effect shader output gets darker over time? 0 Answers
Render UI on a Separate Camera without losing Image Effects? 2 Answers