Java Code Examples for org.opencv.core.CvType#CV_8U
The following examples show how to use
org.opencv.core.CvType#CV_8U .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java From MOAAP with MIT License | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 2
Source File: Utils.java From Android-Car-duino with GNU General Public License v2.0 | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Highgui.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 3
Source File: Utils.java From real_time_circle_detection_android with MIT License | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 4
Source File: Utils.java From FaceDetectDemo with Apache License 2.0 | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 5
Source File: Utils.java From Image-Detection-Samples with Apache License 2.0 | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 6
Source File: Utils.java From Camdroid with Apache License 2.0 | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 7
Source File: Utils.java From FtcSamples with MIT License | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 8
Source File: Utils.java From OpenCvFaceDetect with Apache License 2.0 | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 9
Source File: Utils.java From OpenCV-android with Apache License 2.0 | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 10
Source File: Utils.java From FaceT with Mozilla Public License 2.0 | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 11
Source File: Utils.java From react-native-documentscanner-android with MIT License | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 12
Source File: Utils.java From pasm-yolov3-Android with GNU General Public License v3.0 | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 13
Source File: Utils.java From AndroidDocumentScanner with MIT License | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 14
Source File: Utils.java From MOAAP with MIT License | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 15
Source File: Utils.java From MOAAP with MIT License | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 16
Source File: Utils.java From ml-authentication with Apache License 2.0 | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 17
Source File: Utils.java From MOAAP with MIT License | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 18
Source File: Utils.java From SoftwarePilot with MIT License | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Highgui.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 19
Source File: DigitRecognizer.java From MOAAP with MIT License | 5 votes |
int FindMatch(Mat test_image) { //Dilate the image Imgproc.dilate(test_image, test_image, Imgproc.getStructuringElement(Imgproc.CV_SHAPE_CROSS, new Size(3,3))); //Resize the image to match it with the sample image size Imgproc.resize(test_image, test_image, new Size(width, height)); //Convert the image to grayscale Imgproc.cvtColor(test_image, test_image, Imgproc.COLOR_RGB2GRAY); //Adaptive Threshold Imgproc.adaptiveThreshold(test_image,test_image,255,Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY_INV,15, 2); Mat test = new Mat(1, test_image.rows() * test_image.cols(), CvType.CV_32FC1); int count = 0; for(int i = 0 ; i < test_image.rows(); i++) { for(int j = 0 ; j < test_image.cols(); j++) { test.put(0, count, test_image.get(i, j)[0]); count++; } } Mat results = new Mat(1, 1, CvType.CV_8U); //K-NN Prediction //return (int)knn.findNearest(test, 10, results); //SVM Prediction return (int)svm.predict(test); }
Example 20
Source File: MatXml.java From Android-Face-Recognition-with-Deep-Learning-Library with Apache License 2.0 | 4 votes |
public void writeMat(String tag, Mat mat) { try { if( isWrite == false) { System.err.println("Try write to file with no write flags"); return; } Element matrix = doc.createElement(tag); matrix.setAttribute("type_id", "opencv-matrix"); rootElement.appendChild(matrix); Element rows = doc.createElement("rows"); rows.appendChild( doc.createTextNode( String.valueOf(mat.rows()) )); Element cols = doc.createElement("cols"); cols.appendChild( doc.createTextNode( String.valueOf(mat.cols()) )); Element dt = doc.createElement("dt"); String dtStr; int type = mat.type(); if(type == CvType.CV_32F ) { // type == CvType.CV_32FC1 dtStr = "f"; } else if( type == CvType.CV_32S ) { // type == CvType.CV_32SC1 dtStr = "i"; } else if( type == CvType.CV_16S ) { // type == CvType.CV_16SC1 dtStr = "s"; } else if( type == CvType.CV_8U ){ // type == CvType.CV_8UC1 dtStr = "b"; } else { dtStr = "unknown"; } dt.appendChild( doc.createTextNode( dtStr )); Element data = doc.createElement("data"); String dataStr = dataStringBuilder( mat ); data.appendChild( doc.createTextNode( dataStr )); // append all to matrix matrix.appendChild( rows ); matrix.appendChild( cols ); matrix.appendChild( dt ); matrix.appendChild( data ); } catch(Exception e) { e.printStackTrace(); } }