OpneCV
opencv 성인 이미지 검사
닉의네임
2020. 12. 31. 13:24
반응형
성인이미지가 등록되기전에 막아보자!
Mat ori = Imgcodecs.imread(filePath + file);
Mat adult = new Mat();
List<Mat> matsBGRA = new ArrayList<>();
Imgproc.cvtColor(ori, adult, Imgproc.COLOR_BGR2YCrCb);
Core.split(adult, matsBGRA);
int nr = adult.rows();
int nc = adult.cols();
int minCr = 128, maxCr = 170, minCb = 73, maxCb = 158;
int sal = 0;
for (int i = 0; i < nr; i++) {
for (int j = 0; j < nc; j++) {
if ((minCr < adult.get(i, j)[1]) && (adult.get(i, j)[1] < maxCr) && (minCb < adult.get(i, j)[2]) && (adult.get(i, j)[2] < maxCb)) {
sal++;
}
}
}
double rate = ((sal * 100) / (nc * nr));
System.out.println(rate);
if (rate > 20) {
System.out.println("adult");
} else {
System.out.println("ok");
}
실패..
반응형