opencv: Having java.lang.Exception: unknown exception with text detection algorithm
System information (version)
- OpenCV => 3.4.3
- Operating System / Platform => Windows 7 64 Bit
- Compiler => using this release : https://github.com/opencv/opencv/releases/download/3.4.3/opencv-3.4.3-vc14_vc15.exe with JDK 8
Detailed description
Hi ! I’m trying to translate this code sample https://github.com/opencv/opencv/blob/3.4/samples/dnn/text_detection.cpp to Java (whithout the video capture part). I downloaded the model here : https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1. I’m having this error : Exception in thread “main” java.lang.Exception: unknown exception at org.opencv.dnn.Net.forward_4(Native Method) at org.opencv.dnn.Net.forward(Net.java:334) at TextDetection.main(TextDetection.java:25)
This error appears when I use the forward() method from the Net object. It seems to me, that when you use the forward method with two parameters (outs and outNames cf below), it won’t work with more than one name. I try with only “feature_fusion/Conv_7/Sigmoid” or “feature_fusion/concat_3” and the method doesn’t fail.
Steps to reproduce
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
//input model
Net net = Dnn.readNet("frozen_east_text_detection.pb");
// input image
Mat frame = Imgcodecs.imread("picture.jpg");
Mat blob = Dnn.blobFromImage(frame, 1.0, new Size(320,320), new Scalar(123.68, 116.78, 103.94), true, false);
net.setInput(blob);
List<Mat> outs = new ArrayList<>(2);
List<String> outNames = Arrays.asList("feature_fusion/Conv_7/Sigmoid", "feature_fusion/concat_3");
net.forward(outs, outNames);
Is there anything I can do to bypass this error ?
Thanks,
Antoine
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (11 by maintainers)
We can close this issue 😃 I’ll check out on how to do a (good) pull request ! Thanks again for everything !
@Zappyford, @berak, try to vary input’s width and height:
It also make sense to check which input size is used in TensorFlow’s demo.
@dkurt
@dkurt i’ve tried in the original sample in C++ with
width=320
andheight=320
and it’s the same. @berak here is my code :Wow ! Ok I’ll try it ! Thank you !
i think, it’s this: https://github.com/opencv/opencv/issues/12324
(the fix didn’t make it into the 3.4.3 release, unfortunately)
@Zappyford , maybe you can take a look, if you have this fix ?
but then, there will be another problem: there is no working java version for NMSBoxesRotated() yet 😭