I am writing a program to convert an image selected from photo library to gray scale in iOS, but when I tested it, the imageView show nothing but darkness. What's wrong with my code?
Here is a part of my code. And I'm pretty sure that there is nothing wrong with my toGray function, which I use to convert an image to gray scale by Open CV.
func didSelectPhoto(_ image: UIImage?) {
if let image = image {
self.setupElementsVisibility(true)
let gray = OpenCVWrapper.toGray(image)
self.imageContainer.image = gray
} else {
self.setupElementsVisibility(true)
}
self.dismiss(animated: true, completion: nil)
}