Commit 2a0f9fcd authored by 宋柯's avatar 宋柯

眉毛

parent 8c372a36
This diff is collapsed.
...@@ -67,6 +67,9 @@ int f_MakeupBaseN(unsigned char* srcData, int width, int height, int stride, int ...@@ -67,6 +67,9 @@ int f_MakeupBaseN(unsigned char* srcData, int width, int height, int stride, int
*ratio: intensity of effect, [0, 100] *ratio: intensity of effect, [0, 100]
*Return: 0-OK,other failed *Return: 0-OK,other failed
**************************************************************************/ **************************************************************************/
#include "iostream"
using namespace std;
using namespace cv;
int f_MakeupBase(unsigned char* srcData, int width, int height, int stride, int srcKeyPoints[2 * 3], unsigned char* mskData, int mWidth, int mHeight, int mStride, int maskKeyPoints[2 * 3], int ratio) int f_MakeupBase(unsigned char* srcData, int width, int height, int stride, int srcKeyPoints[2 * 3], unsigned char* mskData, int mWidth, int mHeight, int mStride, int maskKeyPoints[2 * 3], int ratio)
{ {
int ret = 0; int ret = 0;
...@@ -108,8 +111,27 @@ int f_MakeupBase(unsigned char* srcData, int width, int height, int stride, int ...@@ -108,8 +111,27 @@ int f_MakeupBase(unsigned char* srcData, int width, int height, int stride, int
tmp2 = mskData[index_x0y1 + 3] + ((disX *(mskData[index_x1y1 + 3] - mskData[index_x0y1 + 3])) >> 14); tmp2 = mskData[index_x0y1 + 3] + ((disX *(mskData[index_x1y1 + 3] - mskData[index_x0y1 + 3])) >> 14);
AA = tmp1 + ((disY * (tmp2 - tmp1)) >> 14); AA = tmp1 + ((disY * (tmp2 - tmp1)) >> 14);
int pos = (x0 << 2) + y0 * mStride; // int pos = (x0<<2) + y0 * mStride;
// int k = mskData[pos+3];
// int b = (k * mskData[pos] + (255 - k) * pSrc[0]) / 255;
// int g = (k * mskData[pos+1] + (255 - k) * pSrc[1]) / 255;
// int r = (k * mskData[pos+2] + (255 - k) * pSrc[2]) / 255;
int k = AA; int k = AA;
// int b;
// int g;
// int r;
// if(k){
// b = AB;
// g = AG;
// r = AR;
// }else{
// b = pSrc[0];
// g = pSrc[1];
// r = pSrc[2];
// }
int b = (k * AB + (255 - k) * pSrc[0]) / 255; int b = (k * AB + (255 - k) * pSrc[0]) / 255;
int g = (k * AG + (255 - k) * pSrc[1]) / 255; int g = (k * AG + (255 - k) * pSrc[1]) / 255;
int r = (k * AR + (255 - k) * pSrc[2]) / 255; int r = (k * AR + (255 - k) * pSrc[2]) / 255;
...@@ -122,6 +144,57 @@ int f_MakeupBase(unsigned char* srcData, int width, int height, int stride, int ...@@ -122,6 +144,57 @@ int f_MakeupBase(unsigned char* srcData, int width, int height, int stride, int
} }
return ret; return ret;
}; };
int f_MakeupBaseTest(cv::Mat& srcData, int width, int height, int stride, int srcKeyPoints[2 * 3], Mat& mskData, int mWidth, int mHeight, int mStride, int maskKeyPoints[2 * 3], int ratio,cv::Mat& maskMat)
{
// cv::Mat maskTemp;
// maskTemp.create(maskMat.rows,maskMat.cols,CV_8UC3);
int ret = 0;
float H[6] = {0};
f_AffinetransformMetrixCompute((float)maskKeyPoints[0],(float)maskKeyPoints[1],(float)maskKeyPoints[2],(float)maskKeyPoints[3],(float)maskKeyPoints[4],(float)maskKeyPoints[5], (float)srcKeyPoints[0], (float)srcKeyPoints[1], (float)srcKeyPoints[2], (float)srcKeyPoints[3], (float)srcKeyPoints[4], (float)srcKeyPoints[5], H);
int alpha = 128 * ratio / 100;
int nalpha = 128 - alpha;
// int AR, AG, AB, AA;
int x0, y0, index_x0y0, index_x0y1, index_x1y0, index_x1y1;
// int disX, disY, tmp1, tmp2;
int c1=0,c2=0,c3=0;
set<string> s1;
set<string> s2;
for(int j = 0; j < height; j++)
{
for(int i = 0; i < width; i++)
{
c3++;
float cx = (H[0] * i + H[1] * j + H[2]);
float cy = (H[3] * i + H[4] * j + H[5]);
if(cx > 0 && cx < mWidth - 1 && cy > 0 && cy < mHeight - 1)
{
// circle(srcData,Point(i,j),1,Scalar(0,0,255));
x0 = (int)CLIP3(floor(cx), 0, mWidth - 2);
y0 = (int)CLIP3(floor(cy), 0, mHeight - 2);
// circle(mskData,Point(x0,y0),1,Scalar(0,0,255));
s1.insert(to_string(x0)+"_"+to_string(y0));
Vec4b &vec = mskData.at<Vec4b>(Point(x0, y0));
srcData.at<Vec4b>(Point(i, j)) = vec;
}
}
}
// cv::imshow("maskMat",maskMat);
cout << c1 << endl;
cout << c2 << endl;
cout << c3 << endl;
cout << s1.size() << endl;
cout << s2.size() << endl;
// cv::imshow("maskTemp",maskTemp);
cv::imshow("mskData",mskData);
cv::imshow("srcData",srcData);
cv::waitKey(0);
return ret;
};
inline int ModeSmoothLight(int basePixel,int mixPixel) inline int ModeSmoothLight(int basePixel,int mixPixel)
{ {
int res = 0; int res = 0;
......
#ifndef __T_MAKEUP_BASE__ #ifndef __T_MAKEUP_BASE__
#define __T_MAKEUP_BASE__ #define __T_MAKEUP_BASE__
#include <opencv2/opencv.hpp>
/************************************************************************* /*************************************************************************
*Function: Makeup base *Function: Makeup base
*Params: *Params:
...@@ -13,11 +13,12 @@ ...@@ -13,11 +13,12 @@
*mWidth: width of mask image *mWidth: width of mask image
*mHeight: height of mask image *mHeight: height of mask image
*mStride: Stride of mask image *mStride: Stride of mask image
*maskKeyPoints 3 key points of blush mask. *maskKeyPoints�� 3 key points of blush mask.
*ratio: intensity of effect, [0, 100] *ratio: intensity of effect, [0, 100]
*Return: 0-OK,other failed *Return: 0-OK,other failed
**************************************************************************/ **************************************************************************/
int f_MakeupBase(unsigned char* srcData, int width, int height, int stride, int srcKeyPoints[2 * 3], unsigned char* mskData, int mWidth, int mHeight, int mStride, int maskKeyPoints[2 * 3], int ratio); int f_MakeupBase(unsigned char* srcData, int width, int height, int stride, int srcKeyPoints[2 * 3], unsigned char* mskData, int mWidth, int mHeight, int mStride, int maskKeyPoints[2 * 3], int ratio);
int f_MakeupBaseTest(cv::Mat& srcData, int width, int height, int stride, int srcKeyPoints[2 * 3], cv::Mat& mskData, int mWidth, int mHeight, int mStride, int maskKeyPoints[2 * 3], int ratio,cv::Mat& maskMat);
/************************************************************************* /*************************************************************************
*Function: f_MakeupBaseShadow *Function: f_MakeupBaseShadow
*Params: *Params:
...@@ -30,7 +31,7 @@ int f_MakeupBase(unsigned char* srcData, int width, int height, int stride, int ...@@ -30,7 +31,7 @@ int f_MakeupBase(unsigned char* srcData, int width, int height, int stride, int
*mWidth: width of mask image *mWidth: width of mask image
*mHeight: height of mask image *mHeight: height of mask image
*mStride: Stride of mask image *mStride: Stride of mask image
*maskKeyPoints 4 key points of eyeshadow mask. *maskKeyPoints�� 4 key points of eyeshadow mask.
*mode: overlay mode. *mode: overlay mode.
*ratio: intensity of effect, [0, 100] *ratio: intensity of effect, [0, 100]
*Return: 0-OK,other failed *Return: 0-OK,other failed
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment