OpenCV

Posted by Adam on August 24, 2022
```java public static Mat readHttpImage(String url) throws IOException { // 讀取 URL 並轉換為 InputStream URL imageUrl = new URL(url); InputStream stream = imageUrl.openStream(); // 將 InputStream 轉換為 byte[] byte[] bytes = stream.readAllBytes(); // 將 byte[] 轉換為 Mat Mat image = Imgcodecs.imdecode(new MatOfByte(bytes), Imgcodecs.IMREAD_UNCHANGED); return image; } ```