Created
February 24, 2020 03:50
-
-
Save choowilson/683cdbfe4821c88fd853b54c2a78c73d to your computer and use it in GitHub Desktop.
If you are using a pair of NativeImageLoader from DataVec and opencv's imshow. You need to divide the matrix by 255(normalize) first else only a white image will appear. If you use opencv imread and imshow as a pair then there will be no problem.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.datavec.image.loader.NativeImageLoader; | |
import org.nd4j.linalg.api.ndarray.INDArray; | |
import static org.bytedeco.opencv.global.opencv_highgui.*; | |
NativeImageLoader nil = new NativeImageLoader(416,416, 3); | |
INDArray image = nil.asMatrix("C:\\Users\\choowilson\\Desktop\\potato.jpg").div(255.0); | |
Mat mat = nil.asMat(image); | |
imshow("Output",mat); | |
waitKey(0); | |
destroyAllWindows(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment