Skip to content

Commit

Permalink
Fix OSX build
Browse files Browse the repository at this point in the history
  • Loading branch information
vinjn committed May 29, 2016
1 parent 40cdbb5 commit 22dc4a1
Show file tree
Hide file tree
Showing 10 changed files with 591 additions and 481 deletions.
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,23 @@
/vc2013/*.opensdf
/vc2013/*.sdf
/assets/MiniConfig.xml

## Build generated
build/
DerivedData/
*.xcworkspace

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
6 changes: 3 additions & 3 deletions assets/shader/clone.frag
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ in vec2 TexCoord;
out highp vec4 Color;

void main() {
vec4 srcColorBlur = texture2D(srcBlur, TexCoord);
vec4 srcColorBlur = texture(srcBlur, TexCoord);
if(srcColorBlur.a > 0.) {
vec3 srcColor = texture2D(src, TexCoord).rgb;
vec3 dstColorBlur = texture2D(dstBlur, TexCoord).rgb;
vec3 srcColor = texture(src, TexCoord).rgb;
vec3 dstColorBlur = texture(dstBlur, TexCoord).rgb;
vec3 offset = (dstColorBlur.rgb - srcColorBlur.rgb);
Color = vec4(srcColor + offset, 1.);
} else {
Expand Down
10 changes: 5 additions & 5 deletions assets/shader/maskBlur.frag
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ out highp vec4 Color;

void main() {
vec2 dir = direction / ciWindowSize;
vec4 sum = texture2D(tex, TexCoord);
vec4 sum = texture(tex, TexCoord);
int i;
for(i = 1; i < strength; i++) {
vec2 curOffset = float(i) * dir;
vec4 leftMask = texture2D(mask, TexCoord - curOffset);
vec4 rightMask = texture2D(mask, TexCoord + curOffset);
vec4 leftMask = texture(mask, TexCoord - curOffset);
vec4 rightMask = texture(mask, TexCoord + curOffset);
bool valid = leftMask.r == 1. && rightMask.r == 1.;
if(valid) {
sum +=
texture2D(tex, TexCoord + curOffset) +
texture2D(tex, TexCoord - curOffset);
texture(tex, TexCoord + curOffset) +
texture(tex, TexCoord - curOffset);
} else {
break;
}
Expand Down
2 changes: 2 additions & 0 deletions include/item.def
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ ITEM_DEF(string, MOVIE_PATH, "tutorial_part5_02.mov")
// ITEM_DEF(bool, FLIP, true)
ITEM_DEF(int, DEVICE_ID, 0)
ITEM_DEF(int, PEOPLE_ID, 0)
ITEM_DEF(int, FPS, 0)

5 changes: 3 additions & 2 deletions src/Clone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ void Clone::setup(int width, int height)
catch (const std::exception& e)
{
app::console() << e.what() << std::endl;
app::AppBase::get()->quit();
}

mStrength = 0;
}

void Clone::maskedBlur(gl::TextureRef& tex, gl::TextureRef& mask, gl::FboRef& result)
void Clone::maskedBlur(gl::TextureRef tex, gl::TextureRef mask, gl::FboRef result)
{
gl::ScopedTextureBind t2(mask, 2);
#if 1
Expand Down Expand Up @@ -65,7 +66,7 @@ void Clone::setStrength(int strength)
mStrength = strength;
}

void Clone::update(gl::TextureRef& src, gl::TextureRef& dst, gl::TextureRef& mask)
void Clone::update(gl::TextureRef src, gl::TextureRef dst, gl::TextureRef mask)
{
mMaskBlurShader->uniform("strength", mStrength);

Expand Down
4 changes: 2 additions & 2 deletions src/Clone.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ class Clone {
public:
void setup(int width, int height);
void setStrength(int strength);
void update(ci::gl::TextureRef& src, ci::gl::TextureRef& dst, ci::gl::TextureRef& mask);
void update(ci::gl::TextureRef src, ci::gl::TextureRef dst, ci::gl::TextureRef mask);
void draw(ci::vec2 pos = ci::vec2());

protected:
void maskedBlur(ci::gl::TextureRef& tex, ci::gl::TextureRef& mask, ci::gl::FboRef& result);
void maskedBlur(ci::gl::TextureRef tex, ci::gl::TextureRef mask, ci::gl::FboRef result);
ci::gl::FboRef mBufferFbo, mSrcBlurFbo, mDstBlurFbo;
ci::gl::GlslProgRef mMaskBlurShader, mCloneShader;
int mStrength;
Expand Down
54 changes: 27 additions & 27 deletions src/FaceOffApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
#include "cinder/gl/scoped.h"
#include "cinder/params/Params.h"

#include "cinder/qtime/QuickTimeGl.h"
#include "TextureHelper.h"
#include "cinder/qtime/QuickTimeGl.h"
#include "TextureHelper.h"

#include "CinderOpenCV.h"
#include "ciFaceTracker/ciFacetracker.h"
#include "MiniConfig.h"
#include "Clone.h"
#include "Clone.h"

using namespace ci;
using namespace app;
Expand Down Expand Up @@ -205,40 +205,40 @@ void FaceOff::update()
if (!mMovie)
{
fs::path moviePath = getAssetPath(MOVIE_PATH);
try {
// load up the movie, set it to loop, and begin playing
mMovie = qtime::MovieSurface::create(moviePath);
mMovie->setLoop();
mMovie->play();
mRefTex.reset();
mRenderedRefTex.reset();
}
catch (ci::Exception &exc) {
console() << "Exception caught trying to load the movie from path: " << moviePath << ", what: " << exc.what() << std::endl;
mMovie.reset();
}
try {
// load up the movie, set it to loop, and begin playing
mMovie = qtime::MovieSurface::create(moviePath);
mMovie->setLoop();
mMovie->play();
mRefTex.reset();
mRenderedRefTex.reset();
}
catch (ci::Exception &exc) {
console() << "Exception caught trying to load the movie from path: " << moviePath << ", what: " << exc.what() << std::endl;
mMovie.reset();
}
}
else
{
if (mMovie->checkNewFrame())
{
auto surface = mMovie->getSurface();
if (!mRefTex)
{
mRefTex = gl::Texture2d::create(*surface, gl::Texture::Format().loadTopDown());
}
else
{
mRefTex->update(*surface);
}
auto surface = mMovie->getSurface();
if (!mRefTex)
{
mRefTex = gl::Texture2d::create(*surface, gl::Texture::Format().loadTopDown());
}
else
{
mRefTex->update(*surface);
}
}
}
}
else
{
if (mMovie)
{
mMovie.reset();
mMovie.reset();
}
mRefTex = mPhotoTex;
}
Expand Down Expand Up @@ -373,8 +373,8 @@ void FaceOff::draw()
gl::draw(mRefTex);
}

gl::drawStringCentered("fps: " + toString(getAverageFps()), vec2(150, 10));

FPS = getAverageFps();
gl::disableAlphaBlending();

if (WIREFRAME_MODE && mOnlineTracker.getFound())
Expand Down
2 changes: 1 addition & 1 deletion src/ciFaceTracker/FaceTracker/Patch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
///////////////////////////////////////////////////////////////////////////////
#include "Patch.h"
#define SGN(x) (x<0) ? 0:1
#define SGN(x) ((x<0) ? 0:1)
using namespace FACETRACKER;
using namespace std;
//===========================================================================
Expand Down
5 changes: 4 additions & 1 deletion src/ciFaceTracker/ciFaceTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ bool ciFaceTracker::update(Mat image) {
resize(image, mIm, cv::Size(mRescale * image.cols, mRescale * image.rows));
}

if (mIm.channels() == 3)
int nChannels = mIm.channels();
if (nChannels == 3)
cvtColor(mIm, mGray, CV_RGB2GRAY);
else if (nChannels == 4)
cvtColor(mIm, mGray, CV_RGBA2GRAY);
else
mGray = mIm;
mImgSize = { image.cols, image.rows };
Expand Down
Loading

0 comments on commit 22dc4a1

Please sign in to comment.