Add more functions
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package Other;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.bytedeco.javacpp.Loader;
|
||||
import org.bytedeco.javacv.Frame;
|
||||
import org.bytedeco.javacv.Java2DFrameConverter;
|
||||
@@ -42,6 +43,7 @@ public class SomeCodes {
|
||||
public static final boolean haveOpenCL = opencv_core.haveOpenCL();
|
||||
public static boolean useOpenCL;
|
||||
private static final Base64.Encoder base64encoder = java.util.Base64.getEncoder();
|
||||
public static final Gson gson = new Gson();
|
||||
|
||||
public static String[] GetAudioFiles(){
|
||||
try{
|
||||
@@ -49,6 +51,7 @@ public class SomeCodes {
|
||||
} catch (Exception e){
|
||||
Logger.error("Error getting audio files: "+e.getMessage());
|
||||
}
|
||||
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@@ -199,10 +202,15 @@ public class SomeCodes {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load properties file
|
||||
* @param filename properties file name
|
||||
* @return Properties object loaded, or empty new Properties object if error
|
||||
*/
|
||||
public static @NotNull Properties LoadProperties(String filename){
|
||||
try{
|
||||
InputStream is = new FileInputStream(filename);
|
||||
File ff = new File(currentDirectory, filename);
|
||||
InputStream is = new FileInputStream(ff);
|
||||
Properties prop = new Properties();
|
||||
prop.load(is);
|
||||
return prop;
|
||||
@@ -212,9 +220,16 @@ public class SomeCodes {
|
||||
return new Properties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save properties file
|
||||
* @param prop Properties object to save
|
||||
* @param filename properties file name
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
public static boolean SaveProperties(Properties prop, String filename){
|
||||
try{
|
||||
OutputStream os = new FileOutputStream(filename);
|
||||
File ff = new File(currentDirectory, filename);
|
||||
OutputStream os = new FileOutputStream(ff);
|
||||
prop.store(os, null);
|
||||
return true;
|
||||
} catch (Exception e){
|
||||
@@ -236,6 +251,7 @@ public class SomeCodes {
|
||||
UMat src = new UMat();
|
||||
source.copyTo(src);
|
||||
UMat dst = new UMat();
|
||||
|
||||
opencv_imgproc.resize(src, dst, sz);
|
||||
dst.copyTo(dest);
|
||||
} else {
|
||||
@@ -249,4 +265,19 @@ public class SomeCodes {
|
||||
Mat resized = ResizeMat(mat, width, height);
|
||||
return matConverter.convert(resized);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if an ip address is reachable
|
||||
* @param ipaddress ip address to check
|
||||
* @return true if valid and reachable, false otherwise
|
||||
*/
|
||||
public static boolean IpIsReachable(String ipaddress){
|
||||
try{
|
||||
InetAddress inet = InetAddress.getByName(ipaddress);
|
||||
return inet.isReachable(1000);
|
||||
} catch (Exception e){
|
||||
Logger.error("Error checking ip address: "+e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user