Beispiel #1
0
 virtual bool is_equal(const MutableMatrix *B) const
 {
   const MutableMat *B1 = dynamic_cast<const MutableMat *>(B);
   if (B1 == NULL || &B1->getMat().ring() != &getMat().ring())
     return false;
   return getMat().is_equal(B1->getMat());
 }
Beispiel #2
0
void getParamMats(double ****paramMats, int hiddenLayerNum,int inputSize, int *layerSizes)
{
    (*paramMats) = (double ***)malloc(sizeof(double **)*hiddenLayerNum);
    int ctr;
    (*paramMats)[0] = getMat(inputSize, layerSizes[0]);
    for (ctr = 1; ctr < hiddenLayerNum; ctr++)
    {
        (*paramMats)[ctr] = getMat(layerSizes[ctr-1], layerSizes[ctr]);
    }
}
Beispiel #3
0
void UMat::convertTo(OutputArray _dst, int _type, double alpha, double beta) const
{
    bool noScale = std::fabs(alpha - 1) < DBL_EPSILON && std::fabs(beta) < DBL_EPSILON;
    int stype = type(), cn = CV_MAT_CN(stype);

    if( _type < 0 )
        _type = _dst.fixedType() ? _dst.type() : stype;
    else
        _type = CV_MAKETYPE(CV_MAT_DEPTH(_type), cn);

    int sdepth = CV_MAT_DEPTH(stype), ddepth = CV_MAT_DEPTH(_type);
    if( sdepth == ddepth && noScale )
    {
        copyTo(_dst);
        return;
    }
#ifdef HAVE_OPENCL
    bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0;
    bool needDouble = sdepth == CV_64F || ddepth == CV_64F;
    if( dims <= 2 && cn && _dst.isUMat() && ocl::useOpenCL() &&
            ((needDouble && doubleSupport) || !needDouble) )
    {
        int wdepth = std::max(CV_32F, sdepth), rowsPerWI = 4;

        char cvt[2][40];
        ocl::Kernel k("convertTo", ocl::core::convert_oclsrc,
                      format("-D srcT=%s -D WT=%s -D dstT=%s -D convertToWT=%s -D convertToDT=%s%s%s",
                             ocl::typeToStr(sdepth), ocl::typeToStr(wdepth), ocl::typeToStr(ddepth),
                             ocl::convertTypeStr(sdepth, wdepth, 1, cvt[0]),
                             ocl::convertTypeStr(wdepth, ddepth, 1, cvt[1]),
                             doubleSupport ? " -D DOUBLE_SUPPORT" : "", noScale ? " -D NO_SCALE" : ""));
        if (!k.empty())
        {
            UMat src = *this;
            _dst.create( size(), _type );
            UMat dst = _dst.getUMat();

            float alphaf = (float)alpha, betaf = (float)beta;
            ocl::KernelArg srcarg = ocl::KernelArg::ReadOnlyNoSize(src),
                    dstarg = ocl::KernelArg::WriteOnly(dst, cn);

            if (noScale)
                k.args(srcarg, dstarg, rowsPerWI);
            else if (wdepth == CV_32F)
                k.args(srcarg, dstarg, alphaf, betaf, rowsPerWI);
            else
                k.args(srcarg, dstarg, alpha, beta, rowsPerWI);

            size_t globalsize[2] = { (size_t)dst.cols * cn, ((size_t)dst.rows + rowsPerWI - 1) / rowsPerWI };
            if (k.run(2, globalsize, NULL, false))
            {
                CV_IMPL_ADD(CV_IMPL_OCL);
                return;
            }
        }
    }
#endif
    Mat m = getMat(ACCESS_READ);
    m.convertTo(_dst, _type, alpha, beta);
}
Beispiel #4
0
static PyObject* pyAddMatCamera(PyObject *self, PyObject *args) {
	int id;
	if(!PyArg_ParseTuple(args, "i", &id))
		return NULL;
	
	addMatCamera(getMat(id));
	Py_RETURN_NONE;
}
Beispiel #5
0
static PyObject* pyAddMatCameraAntiRotation(PyObject *self, PyObject *args) {
  int matType;
  if(!PyArg_ParseTuple(args, "i", &matType))
    return NULL;
  
  addMatCameraAntiRotation(getMat(matType));
  Py_RETURN_NONE;
}
Beispiel #6
0
static PyObject* pySetMatIdentity(PyObject *self, PyObject *args) {
	int matType;
	if(!PyArg_ParseTuple(args, "i", &matType))
      return NULL;
  
	setMatIdentity(getMat(matType));
	Py_RETURN_NONE;
}
Beispiel #7
0
static PyObject* pyAddMatRotationZ(PyObject *self, PyObject *args) {
	int matType;
	double degZ;
	if(!PyArg_ParseTuple(args, "id", &matType, &degZ))
      return NULL;
  
	addMatRotationZ(getMat(matType), degZ);
	Py_RETURN_NONE;
}
Beispiel #8
0
static PyObject* pySetMatRotationY(PyObject *self, PyObject *args) {
	int matType;
	double degY;	
	if(!PyArg_ParseTuple(args, "id", &matType, &degY))
      return NULL;
  
	setMatRotationY(getMat(matType), degY);		
	Py_RETURN_NONE;
}	
Beispiel #9
0
static PyObject* pySetMatScale(PyObject *self, PyObject *args) {
	int matType;
	double sx,sy,sz;
	if(!PyArg_ParseTuple(args, "iddd", &matType, &sx, &sy, &sz))
      return NULL;
  
	setMatScale(getMat(matType), sx, sy, sz);
	Py_RETURN_NONE;
}
Beispiel #10
0
static PyObject* pySetMatTranslation(PyObject *self, PyObject *args) {
	int matType;
	double x,y,z;
	if(!PyArg_ParseTuple(args, "iddd", &matType, &x,&y,&z))
      return NULL;
  
	setMatTranslation(getMat(matType), x,y,z);
	Py_RETURN_NONE;
}
Beispiel #11
0
static PyObject* pyAddMatAntiLook(PyObject *self, PyObject *args) {
	int matType;
	double x,y,z, nx,ny,nz, upx,upy,upz;
	if(!PyArg_ParseTuple(args, "iddddddddd", &matType, &x,&y,&z, &nx,&ny,&nz, &upx,&upy,&upz))
		return NULL;

	addMatAntiLook(getMat(matType), x,y,z, nx,ny,nz, upx,upy,upz);
	Py_RETURN_NONE;
}
Beispiel #12
0
static PyObject* pyAddMatPerspective(PyObject *self, PyObject *args) {
	int matType;
	double fov;
	if(!PyArg_ParseTuple(args, "id", &matType, &fov))
      return NULL;
  
	addMatPerspective(getMat(matType), fov);
	Py_RETURN_NONE;
}
Beispiel #13
0
UMat& UMat::setTo(InputArray _value, InputArray _mask)
{
    bool haveMask = !_mask.empty();
#ifdef HAVE_OPENCL
    int tp = type(), cn = CV_MAT_CN(tp), d = CV_MAT_DEPTH(tp);

    if( dims <= 2 && cn <= 4 && CV_MAT_DEPTH(tp) < CV_64F && ocl::useOpenCL() )
    {
        Mat value = _value.getMat();
        CV_Assert( checkScalar(value, type(), _value.kind(), _InputArray::UMAT) );
        int kercn = haveMask || cn == 3 ? cn : std::max(cn, ocl::predictOptimalVectorWidth(*this)),
                kertp = CV_MAKE_TYPE(d, kercn);

        double buf[16] = { 0, 0, 0, 0, 0, 0, 0, 0,
                           0, 0, 0, 0, 0, 0, 0, 0 };
        convertAndUnrollScalar(value, tp, (uchar *)buf, kercn / cn);

        int scalarcn = kercn == 3 ? 4 : kercn, rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1;
        String opts = format("-D dstT=%s -D rowsPerWI=%d -D dstST=%s -D dstT1=%s -D cn=%d",
                             ocl::memopTypeToStr(kertp), rowsPerWI,
                             ocl::memopTypeToStr(CV_MAKETYPE(d, scalarcn)),
                             ocl::memopTypeToStr(d), kercn);

        ocl::Kernel setK(haveMask ? "setMask" : "set", ocl::core::copyset_oclsrc, opts);
        if( !setK.empty() )
        {
            ocl::KernelArg scalararg(0, 0, 0, 0, buf, CV_ELEM_SIZE(d) * scalarcn);
            UMat mask;

            if( haveMask )
            {
                mask = _mask.getUMat();
                CV_Assert( mask.size() == size() && mask.type() == CV_8UC1 );
                ocl::KernelArg maskarg = ocl::KernelArg::ReadOnlyNoSize(mask),
                        dstarg = ocl::KernelArg::ReadWrite(*this);
                setK.args(maskarg, dstarg, scalararg);
            }
            else
            {
                ocl::KernelArg dstarg = ocl::KernelArg::WriteOnly(*this, cn, kercn);
                setK.args(dstarg, scalararg);
            }

            size_t globalsize[] = { cols * cn / kercn, (rows + rowsPerWI - 1) / rowsPerWI };
            if( setK.run(2, globalsize, NULL, false) )
            {
                CV_IMPL_ADD(CV_IMPL_OCL);
                return *this;
            }
        }
    }
#endif
    Mat m = getMat(haveMask ? ACCESS_RW : ACCESS_WRITE);
    m.setTo(_value, _mask);
    return *this;
}
Beispiel #14
0
static PyObject* pySetMatCamera(PyObject *self, PyObject *args) {
	int matType;
	if(!PyArg_ParseTuple(args, "i", &matType)) {
		printf("Failed to parse pySetMatCamera tuple!\n");
		return NULL;
	}
	
	setMatCamera(getMat(matType));
	Py_RETURN_NONE;
}
Beispiel #15
0
    void showDiff(InputArray gold_, InputArray actual_, double eps)
    {
        Mat gold = getMat(gold_);
        Mat actual = getMat(actual_);

        Mat diff;
        absdiff(gold, actual, diff);
        threshold(diff, diff, eps, 255.0, cv::THRESH_BINARY);

        namedWindow("gold", WINDOW_NORMAL);
        namedWindow("actual", WINDOW_NORMAL);
        namedWindow("diff", WINDOW_NORMAL);

        imshow("gold", gold);
        imshow("actual", actual);
        imshow("diff", diff);

        waitKey();
    }
Beispiel #16
0
static PyObject* pyAddMatScale(PyObject *self, PyObject *args) {
	int matType;
	double sx,sy,sz;
	if(!PyArg_ParseTuple(args, "iddd", &matType, &sx, &sy, &sz)) {
		printf("Failed to parse pyAddMatScale tuple!\n");
		return NULL;
	}
	
	addMatScale(getMat(matType), sx, sy, sz);
	Py_RETURN_NONE;
}
Beispiel #17
0
double UMat::dot(InputArray m) const
{
    CV_Assert(m.sameSize(*this) && m.type() == type());

#ifdef HAVE_OPENCL
    double r = 0;
    CV_OCL_RUN_(dims <= 2, ocl_dot(*this, m, r), r)
#endif

    return getMat(ACCESS_READ).dot(m);
}
Beispiel #18
0
	mat mat::cofactor()
	{
		mat* rez = new mat(dim);
		for (int i = 0; i < dim; i++) {
			for (int j = 0; j < dim; j++) {
				mat aux_mat = getMat(i, j);
				float aux_det = det(aux_mat);
				rez->m[i][j] = m[i][j] * pow(-1, i + j) * aux_det;
			}
		}
		return *rez;
	}
Beispiel #19
0
 virtual MutableMatrix * submatrix(M2_arrayint cols) const
 {
   for (size_t c = 0; c<cols->len; c++)
     if (cols->array[c] < 0 || cols->array[c] >= n_cols())
       {
         ERROR("column index %d out of bounds 0..%d", cols->array[c], n_cols()-1);
         return 0;
       }
   MutableMat *result = new MutableMat(*this); // zero matrix, over the same ring
   result->getMat().setFromSubmatrix(getMat(), cols);
   return result;
 }
Beispiel #20
0
int gamehsp::deleteMat( int id )
{
	gpmat *mat = getMat( id );
	if ( mat == NULL ) return -1;
	mat->_flag = GPMAT_FLAG_NONE;
	if ( mat->_mesh ) {
		delete mat->_mesh;
		mat->_mesh = NULL;
	}
    SAFE_RELEASE( mat->_material );
	return 0;
}
Beispiel #21
0
 virtual MutableMat * subtract(const MutableMatrix *B) const
 // return this - B.  return NULL of sizes or types do not match.
 {
   const MutableMat *B1 = dynamic_cast<const MutableMat *>(B);
   if (B1 == NULL || &B1->getMat().ring() != &getMat().ring())
     {
       ERROR("expected matrices with same sparsity and same base ring");
       return 0;
     }
   MutableMat *result = clone();
   result->getMat().subtractInPlace(B1->getMat());
   return result;
 }
Beispiel #22
0
    AssertionResult assertMatNear(const char* expr1, const char* expr2, const char* eps_expr, InputArray m1_, InputArray m2_, double eps)
    {
        Mat m1 = getMat(m1_);
        Mat m2 = getMat(m2_);

        if (m1.size() != m2.size())
        {
            return AssertionFailure() << "Matrices \"" << expr1 << "\" and \"" << expr2 << "\" have different sizes : \""
                                      << expr1 << "\" [" << PrintToString(m1.size()) << "] vs \""
                                      << expr2 << "\" [" << PrintToString(m2.size()) << "]";
        }

        if (m1.type() != m2.type())
        {
            return AssertionFailure() << "Matrices \"" << expr1 << "\" and \"" << expr2 << "\" have different types : \""
                                      << expr1 << "\" [" << PrintToString(MatType(m1.type())) << "] vs \""
                                      << expr2 << "\" [" << PrintToString(MatType(m2.type())) << "]";
        }

        Mat diff;
        absdiff(m1.reshape(1), m2.reshape(1), diff);

        double maxVal = 0.0;
        Point maxLoc;
        minMaxLocGold(diff, 0, &maxVal, 0, &maxLoc);

        if (maxVal > eps)
        {
            return AssertionFailure() << "The max difference between matrices \"" << expr1 << "\" and \"" << expr2
                                      << "\" is " << maxVal << " at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ")"
                                      << ", which exceeds \"" << eps_expr << "\", where \""
                                      << expr1 << "\" at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ") evaluates to " << printMatVal(m1, maxLoc) << ", \""
                                      << expr2 << "\" at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ") evaluates to " << printMatVal(m2, maxLoc) << ", \""
                                      << eps_expr << "\" evaluates to " << eps;
        }

        return AssertionSuccess();
    }
Beispiel #23
0
bool SLEvaluatorConcrete<RT>::evaluate(const MutableMatrix* inputs, MutableMatrix* outputs)
{
  auto inp = dynamic_cast<const MutableMat< DMat<RT> >*>(inputs);
  auto out = dynamic_cast<MutableMat< DMat<RT> >*>(outputs);
  if (inp == nullptr) { 
    ERROR("inputs: expected a dense mutable matrix");
    return false;
  }
  if (out == nullptr) { 
    ERROR("outputs: expected a dense mutable matrix");
    return false;
  }
  if (&ring() != &inp->getMat().ring()) { 
    ERROR("inputs are in a different ring");
    return false;
  }
  if (&ring() != &out->getMat().ring()) { 
    ERROR("outputs are in a different ring");
    return false;
  }
  
  return evaluate(inp->getMat(),out->getMat());
}
Beispiel #24
0
void Contour::setOrientation(){
	// Copy points to mat ;
	Mat pts = getMat(_points);
	Mat cov(2, 2, CV_64F);
	Mat mean(2, 2, CV_64F);
	Mat value(2, 2, CV_64F);
	Mat vects(2, 2, CV_64F);
	calcCovarMatrix(pts, cov, mean, CV_COVAR_NORMAL | CV_COVAR_ROWS);
	eigen(cov, value, vects);
	_orientation.first = Point2f(vects.at<float>(0, 0), vects.at<float>(0, 1));
	_orientation.second = Point2f(vects.at<float>(1, 0), vects.at<float>(1, 1));

	//_orientation.first  = Point2d(vects.at<double>(0,0), vects.at<double>(0,1)) * sqrt(value.at<double>(0,0));
	//_orientation.second = Point2d(vects.at<double>(1,0), vects.at<double>(1,1)) * sqrt(value.at<double>(1,0));
	//cout << "First: "<< _orientation.first << "  Second: " << _orientation.second << endl ;
}
Beispiel #25
0
void UMat::copyTo(OutputArray _dst, InputArray _mask) const
{
    if( _mask.empty() )
    {
        copyTo(_dst);
        return;
    }
#ifdef HAVE_OPENCL
    int cn = channels(), mtype = _mask.type(), mdepth = CV_MAT_DEPTH(mtype), mcn = CV_MAT_CN(mtype);
    CV_Assert( mdepth == CV_8U && (mcn == 1 || mcn == cn) );

    if (ocl::useOpenCL() && _dst.isUMat() && dims <= 2)
    {
        UMatData * prevu = _dst.getUMat().u;
        _dst.create( dims, size, type() );

        UMat dst = _dst.getUMat();

        bool haveDstUninit = false;
        if( prevu != dst.u ) // do not leave dst uninitialized
            haveDstUninit = true;

        String opts = format("-D COPY_TO_MASK -D T1=%s -D scn=%d -D mcn=%d%s",
                             ocl::memopTypeToStr(depth()), cn, mcn,
                             haveDstUninit ? " -D HAVE_DST_UNINIT" : "");

        ocl::Kernel k("copyToMask", ocl::core::copyset_oclsrc, opts);
        if (!k.empty())
        {
            k.args(ocl::KernelArg::ReadOnlyNoSize(*this),
                   ocl::KernelArg::ReadOnlyNoSize(_mask.getUMat()),
                   haveDstUninit ? ocl::KernelArg::WriteOnly(dst) :
                                   ocl::KernelArg::ReadWrite(dst));

            size_t globalsize[2] = { cols, rows };
            if (k.run(2, globalsize, NULL, false))
            {
                CV_IMPL_ADD(CV_IMPL_OCL);
                return;
            }
        }
    }
#endif
    Mat src = getMat(ACCESS_READ);
    src.copyTo(_dst, _mask);
}
Beispiel #26
0
void UMat::convertTo(OutputArray _dst, int _type, double alpha, double beta) const
{
    bool noScale = std::fabs(alpha - 1) < DBL_EPSILON && std::fabs(beta) < DBL_EPSILON;
    int stype = type(), cn = CV_MAT_CN(stype);

    if( _type < 0 )
        _type = _dst.fixedType() ? _dst.type() : stype;
    else
        _type = CV_MAKETYPE(CV_MAT_DEPTH(_type), cn);

    int sdepth = CV_MAT_DEPTH(stype), ddepth = CV_MAT_DEPTH(_type);
    if( sdepth == ddepth && noScale )
    {
        copyTo(_dst);
        return;
    }

    bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0;
    bool needDouble = sdepth == CV_64F || ddepth == CV_64F;
    if( dims <= 2 && cn && _dst.isUMat() && ocl::useOpenCL() &&
            ((needDouble && doubleSupport) || !needDouble) )
    {
        char cvt[40];
        ocl::Kernel k("convertTo", ocl::core::convert_oclsrc,
                      format("-D srcT=%s -D dstT=%s -D convertToDT=%s%s", ocl::typeToStr(sdepth),
                             ocl::typeToStr(ddepth), ocl::convertTypeStr(CV_32F, ddepth, 1, cvt),
                             doubleSupport ? " -D DOUBLE_SUPPORT" : ""));
        if (!k.empty())
        {
            UMat src = *this;
            _dst.create( size(), _type );
            UMat dst = _dst.getUMat();

            float alphaf = (float)alpha, betaf = (float)beta;
            k.args(ocl::KernelArg::ReadOnlyNoSize(src), ocl::KernelArg::WriteOnly(dst, cn), alphaf, betaf);

            size_t globalsize[2] = { dst.cols * cn, dst.rows };
            if (k.run(2, globalsize, NULL, false))
                return;
        }
    }

    Mat m = getMat(ACCESS_READ);
    m.convertTo(_dst, _type, alpha, beta);
}
Beispiel #27
0
UMat& UMat::setTo(InputArray _value, InputArray _mask)
{
    bool haveMask = !_mask.empty();
    int tp = type(), cn = CV_MAT_CN(tp);
    if( dims <= 2 && cn <= 4 && cn != 3 && ocl::useOpenCL() )
    {
        Mat value = _value.getMat();
        CV_Assert( checkScalar(value, type(), _value.kind(), _InputArray::UMAT) );
        double buf[4];
        convertAndUnrollScalar(value, tp, (uchar*)buf, 1);

        char opts[1024];
        sprintf(opts, "-D dstT=%s", ocl::memopTypeToStr(tp));

        ocl::Kernel setK(haveMask ? "setMask" : "set", ocl::core::copyset_oclsrc, opts);
        if( !setK.empty() )
        {
            ocl::KernelArg scalararg(0, 0, 0, buf, CV_ELEM_SIZE(tp));
            UMat mask;

            if( haveMask )
            {
                mask = _mask.getUMat();
                CV_Assert( mask.size() == size() && mask.type() == CV_8U );
                ocl::KernelArg maskarg = ocl::KernelArg::ReadOnlyNoSize(mask);
                ocl::KernelArg dstarg = ocl::KernelArg::ReadWrite(*this);
                setK.args(maskarg, dstarg, scalararg);
            }
            else
            {
                ocl::KernelArg dstarg = ocl::KernelArg::WriteOnly(*this);
                setK.args(dstarg, scalararg);
            }

            size_t globalsize[] = { cols, rows };
            if( setK.run(2, globalsize, 0, false) )
                return *this;
        }
    }
    Mat m = getMat(haveMask ? ACCESS_RW : ACCESS_WRITE);
    m.setTo(_value, _mask);
    return *this;
}
Beispiel #28
0
bool System::checkDimensions(void){
	uint fil[mat::MATRIX_NO]={n,n,p,p,n,n,n  ,n*p,0,0};
	uint col[mat::MATRIX_NO]={n,m,n,m,n,m,n*m,n  ,0,0};
		
	bool test = true;
	for (int i = 0; i <= mat::obser; i++) {
		Mat *matrix = getMat(i);
		
		if ( matrix != 0 ) {
			if ( (uint)matrix->cols != col[i] || (uint)matrix->rows != fil[i] ){
				string reporte="Error en la matriz ";
				reporte += mat_name[i];
				
				test = false;

				if (notify != 0)
					notify->reportStatus(__func__,reporte.c_str());
			}
		}
	}
	return test;
}
Beispiel #29
0
void UMat::copyTo(OutputArray _dst, InputArray _mask) const
{
    if( _mask.empty() )
    {
        copyTo(_dst);
        return;
    }

    int cn = channels(), mtype = _mask.type(), mdepth = CV_MAT_DEPTH(mtype), mcn = CV_MAT_CN(mtype);
    CV_Assert( mdepth == CV_8U && (mcn == 1 || mcn == cn) );

    if (ocl::useOpenCL() && _dst.isUMat() && dims <= 2)
    {
        UMatData * prevu = _dst.getUMat().u;
        _dst.create( dims, size, type() );

        UMat dst = _dst.getUMat();

        if( prevu != dst.u ) // do not leave dst uninitialized
            dst = Scalar(0);

        ocl::Kernel k("copyToMask", ocl::core::copyset_oclsrc,
                      format("-D COPY_TO_MASK -D T=%s -D scn=%d -D mcn=%d",
                             ocl::memopTypeToStr(depth()), cn, mcn));
        if (!k.empty())
        {
            k.args(ocl::KernelArg::ReadOnlyNoSize(*this), ocl::KernelArg::ReadOnlyNoSize(_mask.getUMat()),
                   ocl::KernelArg::WriteOnly(dst));

            size_t globalsize[2] = { cols, rows };
            if (k.run(2, globalsize, NULL, false))
                return;
        }
    }

    Mat src = getMat(ACCESS_READ);
    src.copyTo(_dst, _mask);
}
Beispiel #30
0
void testApp::update() {
	Mat mat = getMat(depthImage);
	
	Sobel(mat, sobelxy, CV_32F, 1, 1);
	sobelxy = abs(sobelxy);
	boxFilter(sobelxy, sobelbox, 0, cv::Size(7, 7));
	
	triangulator.init();
	points.clear();
	int i = 0;
	attempts = 0;
	while(i < 5000) {
		Point2d curPosition((int) ofRandom(sobelbox.cols - 1), (int) ofRandom(sobelbox.rows - 1));
		float curSample = sobelbox.at<unsigned char>(curPosition) / 255.f;
		float curGauntlet = powf(ofRandom(0, 1), 2 * (float) mouseX / ofGetWidth());
		if(curSample > curGauntlet) {
			points.push_back(makeVec(curPosition));
			triangulator.addPoint(curPosition.x, curPosition.y);
			sobelbox.at<unsigned char>(curPosition) = 0; // don't do the same point twice
			i++;
		}
		attempts++;
		if(i > attempts * 100) {
			break;
		}
	}
	
	int w = mat.cols - 1;
	int h = mat.rows - 1;
	triangulator.addPoint(0, 0);
	triangulator.addPoint(w, 0);
	triangulator.addPoint(w, h);
	triangulator.addPoint(0, h);
	
	triangulator.triangulate();	
}