MCPcopy Create free account
hub / github.com/KAlO2/PerfectShow / screen

Function screen

jni/platform/com_cloudream_ishow_algorithm_FaceDetector.cpp:548–581  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

546}
547
548void screen(cv::Mat& dst, const cv::Mat& src, const cv::Mat& mask, const cv::Point2i& position, float amount/* = 1.0f */)
549{
550 assert(src.channels() == 4 && dst.channels() == 4 && src.depth() == dst.depth());
551 assert(mask.type() == CV_8UC1);
552
553 Rect2i rect1(position.x, position.y, src.cols, src.rows);
554 Rect2i rect2(0, 0, dst.cols, dst.rows);
555 rect1 &= rect2;
556
557 Rect2i rect_mask(0, 0, mask.cols, mask.rows);
558 int offset_x = (src.cols - mask.cols)/2;
559 int offset_y = (src.rows - mask.rows)/2;
560
561 for(int r = rect1.y; r < (rect1.y + rect1.height); ++r)
562 for(int c = rect1.x; c < (rect1.x + rect1.width); ++c)
563 {
564 int src_r = r - position.y, src_c = c - position.x;
565 Point2i mask_position(src_c - offset_x, src_r - offset_y);
566 if(!rect_mask.contains(mask_position) || mask.at<uchar>(mask_position) != 0)
567 continue;
568
569 const cv::Vec4b& src_color = src.at<cv::Vec4b>(src_r, src_c);
570
571 cv::Vec4b& dst_color = dst.at<cv::Vec4b>(r, c);
572 const int src_alpha = cvRound(src_color[3] * amount), isc_alpha = 255 - src_alpha;
573
574 for(int i = 0; i < 3; ++i)
575 {
576 int sc = (src_color[i] * src_alpha + 127)/255;
577 int dc = (dst_color[i] * isc_alpha + 127)/255;
578 dst_color[i] = sc + dc - (2*sc*dc + 127)/255;
579 }
580 }
581}
582
583void JNICALL Java_com_cloudream_ishow_algorithm_FaceDetector_nativeBlendIris(JNIEnv *env,
584 jclass clazz, jobject _image, jobject _iris, jobjectArray _points, jfloat amount)

Calls

no outgoing calls

Tested by

no test coverage detected