Skip to content

Commit

Permalink
Added new enum for blurring -> updated c++ and javascript code
Browse files Browse the repository at this point in the history
- npm packages upgrade
  • Loading branch information
kalwalt committed Sep 12, 2024
1 parent cc1144b commit 82c08b6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions WebARKit/WebARKitManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand Down Expand Up @@ -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<double> WebARKitTracker::getOutputData() { return _trackerImpl->getOutputData(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ enum ColorSpace {
GRAY = 2
};

enum BLUR_TYPE {
MEDIAN_BLUR = 0,
BOX_BLUR = 1,
NONE_BLUR = 2
};

} // namespace webarkit

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> getOutputData();

Expand Down
2 changes: 1 addition & 1 deletion WebARKit/include/WebARKitManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> getOutputData();

Expand Down

0 comments on commit 82c08b6

Please sign in to comment.