Package qupath.opencv.io
Class OpenCVTypeAdapters
java.lang.Object
qupath.opencv.io.OpenCVTypeAdapters
Helper classes for combining OpenCV's JSON serialization with Gson's.
 
Sample use:
 Gson gson = new GsonBuilder()
                                .registerTypeAdapterFactory(OpenCVTypeAdapters.getOpenCVTypeAdaptorFactory())
                                .setPrettyPrinting()
                                .create();
 
 Mat mat1 = Mat.eye(3, 3, CV_32F1).asMat();
 String json = gson.toJson(mat1);
 Mat mat2 = gson.fromJson(json, Mat.class);
 - 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classTypeAdapter that helps include OpenCV-based objects within a Java object being serialized to JSON.static classTypeAdapterFactory that helps make OpenCV's serialization methods more compatible with custom JSON/Gson serialization.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic TypeAdapterFactoryGet a TypeAdapterFactory to pass to a GsonBuilder to aid with serializing OpenCV objects (e.g.static <T> TypeAdapter<T> getTypeAdaptor(Class<T> cls) Get a TypeAdapter to pass to a GsonBuilder for a specific supported OpenCV class, i.e.
- 
Constructor Details- 
OpenCVTypeAdapterspublic OpenCVTypeAdapters()
 
- 
- 
Method Details- 
getOpenCVTypeAdaptorFactoryGet a TypeAdapterFactory to pass to a GsonBuilder to aid with serializing OpenCV objects (e.g. Mat, StatModel).- Returns:
 
- 
getTypeAdaptorGet a TypeAdapter to pass to a GsonBuilder for a specific supported OpenCV class, i.e. Mat, SparseMat or StatModel.- Parameters:
- cls-
- Returns:
- the required TypeAdaptor, or null if no supported adapter is available for the class.
 
 
-