diff --git a/WebARKit/WebARKitManager.cpp b/WebARKit/WebARKitManager.cpp index 0914f7e..47e24d6 100644 --- a/WebARKit/WebARKitManager.cpp +++ b/WebARKit/WebARKitManager.cpp @@ -79,7 +79,7 @@ bool WebARKitManager::shutdown() { return true; }; -void WebARKitManager::processFrameData(uchar* frameData, size_t frameCols, size_t frameRows, ColorSpace colorSpace, bool enableBlur) { +void WebARKitManager::processFrameData(uchar* frameData, size_t frameCols, size_t frameRows, ColorSpace colorSpace, BLUR_TYPE blurType, bool enableBlur) { WEBARKIT_LOGd("WebARKitManager::processFrameData(...)\n"); if (state < WAITING_FOR_VIDEO) { WEBARKIT_LOGe("processFrameData called without init the tracker. Call first initTracker.\n"); @@ -88,7 +88,7 @@ void WebARKitManager::processFrameData(uchar* frameData, size_t frameCols, size_ WEBARKIT_LOGe("Error initialising processFrameData.\n"); //return false; } - m_tracker->processFrameData(frameData, frameCols, frameRows, colorSpace, enableBlur); + m_tracker->processFrameData(frameData, frameCols, frameRows, colorSpace, blurType, enableBlur); state = DETECTION_RUNNING; WEBARKIT_LOGd("WebARKitManager::processFrameData() done\n"); } diff --git a/WebARKit/WebARKitTrackers/WebARKitOpticalTracking/WebARKitTracker.cpp b/WebARKit/WebARKitTrackers/WebARKitOpticalTracking/WebARKitTracker.cpp index 0497b87..f907f13 100644 --- a/WebARKit/WebARKitTrackers/WebARKitOpticalTracking/WebARKitTracker.cpp +++ b/WebARKit/WebARKitTrackers/WebARKitOpticalTracking/WebARKitTracker.cpp @@ -155,11 +155,14 @@ class WebARKitTracker::WebARKitTrackerImpl { } void processFrameData(uchar* frameData, size_t frameCols, size_t frameRows, ColorSpace colorSpace, - bool enableBlur) { + BLUR_TYPE blurType, bool enableBlur) { cv::Mat grayFrame = convert2Grayscale(frameData, frameCols, frameRows, colorSpace); - if (enableBlur) { + if (blurType == BLUR_TYPE::BOX_BLUR) { cv::blur(grayFrame, grayFrame, blurSize); } + else if (blurType == BLUR_TYPE::MEDIAN_BLUR) { + cv::medianBlur(grayFrame, grayFrame, blurSize.width); + } processFrame(grayFrame); grayFrame.release(); }; @@ -790,8 +793,8 @@ void WebARKitTracker::initTracker(uchar* refData, size_t refCols, size_t refRows } void WebARKitTracker::processFrameData(uchar* frameData, size_t frameCols, size_t frameRows, ColorSpace colorSpace, - bool enableBlur) { - _trackerImpl->processFrameData(frameData, frameCols, frameRows, colorSpace, enableBlur); + BLUR_TYPE blurType,bool enableBlur) { + _trackerImpl->processFrameData(frameData, frameCols, frameRows, colorSpace, blurType, enableBlur); } std::vector WebARKitTracker::getOutputData() { return _trackerImpl->getOutputData(); } diff --git a/WebARKit/WebARKitTrackers/WebARKitOpticalTracking/include/WebARKitTrackers/WebARKitOpticalTracking/WebARKitEnums.h b/WebARKit/WebARKitTrackers/WebARKitOpticalTracking/include/WebARKitTrackers/WebARKitOpticalTracking/WebARKitEnums.h index 2dca6c4..05d759b 100644 --- a/WebARKit/WebARKitTrackers/WebARKitOpticalTracking/include/WebARKitTrackers/WebARKitOpticalTracking/WebARKitEnums.h +++ b/WebARKit/WebARKitTrackers/WebARKitOpticalTracking/include/WebARKitTrackers/WebARKitOpticalTracking/WebARKitEnums.h @@ -16,6 +16,12 @@ enum ColorSpace { GRAY = 2 }; +enum BLUR_TYPE { + MEDIAN_BLUR = 0, + BOX_BLUR = 1, + NONE_BLUR = 2 +}; + } // namespace webarkit #endif \ No newline at end of file diff --git a/WebARKit/WebARKitTrackers/WebARKitOpticalTracking/include/WebARKitTrackers/WebARKitOpticalTracking/WebARKitTracker.h b/WebARKit/WebARKitTrackers/WebARKitOpticalTracking/include/WebARKitTrackers/WebARKitOpticalTracking/WebARKitTracker.h index 8d2bf61..4e34920 100644 --- a/WebARKit/WebARKitTrackers/WebARKitOpticalTracking/include/WebARKitTrackers/WebARKitOpticalTracking/WebARKitTracker.h +++ b/WebARKit/WebARKitTrackers/WebARKitOpticalTracking/include/WebARKitTrackers/WebARKitOpticalTracking/WebARKitTracker.h @@ -27,7 +27,7 @@ class WebARKitTracker { void initTracker(uchar* refData, size_t refCols, size_t refRows, ColorSpace colorSpace); - void processFrameData(uchar* frameData, size_t frameCols, size_t frameRows, ColorSpace colorSpace, bool enableBlur); + void processFrameData(uchar* frameData, size_t frameCols, size_t frameRows, ColorSpace colorSpace, BLUR_TYPE blurType, bool enableBlur); std::vector getOutputData(); diff --git a/WebARKit/include/WebARKitManager.h b/WebARKit/include/WebARKitManager.h index d1bdffd..a9f9014 100644 --- a/WebARKit/include/WebARKitManager.h +++ b/WebARKit/include/WebARKitManager.h @@ -98,7 +98,7 @@ class WebARKitManager { bool shutdown(); - void processFrameData(uchar* frameData, size_t frameCols, size_t frameRows, ColorSpace colorSpace, bool enableBlur); + void processFrameData(uchar* frameData, size_t frameCols, size_t frameRows, ColorSpace colorSpace, BLUR_TYPE blurType, bool enableBlur); std::vector getOutputData();