void DetailedFaceDetector::detectFeatures(const cv::Mat &frame)
	{
		//get the face rectangles
		RectVector lastRects = getAreas();

		//create a new detailed result
		DetailedFaces newDetails;
	
		for(RectVectorItr faceRect = lastRects.begin(); faceRect != lastRects.end(); ++faceRect)
		{
			//create a new entry
			FaceDetails &currentFace = newDetails[*faceRect];

			if(detectWhat && EYES)
				detectEyes(frame, *faceRect, currentFace);

			if(detectWhat && NOSE)
				detectNose(frame, *faceRect, currentFace);

			if(detectWhat && MOUTH)
				detectMouth(frame, *faceRect, currentFace);
		}

		setDetailedFaceInfo(newDetails);

		notifyControllers();
	}
void FaceDetector::detectFaces(const cv::Mat &frame)
{
    if(faceClassifier.empty())
    {
        return;
    }

    vector<Rect> lastRects = getAreas();
    try
    {
        if(!(optimalSubregionDetect && lastRects.size() > 0))
        {
            vector<Rect> tempRects;
            runFaceDetect(frame, tempRects);
            hasUpdates = setAreas(tempRects);
        }
        else
        {
            detectFacesInROI(lastRects, frame);
        }

    }
    catch (Exception& exc)
    {
        return;
    }
}
Exemple #3
0
void Cage::paint()
{
    int &width = getWidth(0);
    int &height = getHeight(0);

    int maxX = width/cellSize+1;
    int maxY = height/cellSize+1;

    if (maxX >= MATRIX_SIZE || maxY >= MATRIX_SIZE)
        return;

    //size(width, height);
    background(backColor);

    applyWave();
    Areas &areas = getAreas(0);
    for (unsigned int i=0; i<areas.size(); i++) {
        Area &area = areas.at(i);

        if (area.pt[0] > 0 && area.pt[1] > 0 && area.pt[0] < width && area.pt[1] < height) {
            int x1 = (area.pt[0]-(area.width/2 ))/cellSize - influence;
            int y1 = (area.pt[1]-(area.height/2))/cellSize - influence;

            int x2 = (area.pt[0]+(area.width/2 ))/cellSize + influence;
            int y2 = (area.pt[1]+(area.height/2))/cellSize + influence;

            zeroMatrix(x1, y1, x2, y2);
        }
    }

    m[0][0] = 1;
    m[maxX-1][0] = 1;
    color(boxColor);
    for (int i=0; i<maxX; i++)
        for (int j=0; j<maxY; j++)
        {
            if ( i > 0 && m[i-1][j] == 1 && chance(prob/500.0) ) {
                m[i][j] = 1;
            }
            if ( j > 0 && m[i][j-1] == 1 && chance(prob/500.0) ) {
                m[i][j] = 1;
            }
            if ( i < maxX-1 && m[i+1][j] == 1 && chance(prob/500.0) ) {
                m[i][j] = 1;
            }
            if ( j < maxY-1 && m[i][j+1] == 1 && chance(prob/500.0) ) {
                m[i][j] = 1;
            }

            if ( m[i][j] == 1) {
                image(box, i*cellSize+random(boxDeviation)-boxDeviation/2,
                           j*cellSize+random(boxDeviation)-boxDeviation/2, boxSize, boxSize);
            }
        }
}
Exemple #4
0
void Request::executeRequest(const std::string& request) {
	utils::StringUtils util;
	if (!request.empty()) {
		std::vector<std::string> splitRequest = util.split(request,utils::separator);
		std::string type = splitRequest.front();
		if(type == utils::NEW_VISION_AREA) {
				createVisionArea(splitRequest);
		} else if(type ==  utils::MODIFY_VISION_AREA) {
				modifyVisionArea(splitRequest);
		} else if(type == utils::DELETE_VISION_AREA) {
				deleteVisionArea(splitRequest);
		} else if (type==utils::NEW_PRODUCT) {
				createProduct(splitRequest);
		} else if (type == utils::MODIFY_PRODUCT) {
				modifyProduct(splitRequest);
		} else if (type == utils::DELETE_PRODUCT) {
			deleteProduct(splitRequest);
		} else if (type == utils::LIST_AREA) {
			listAreas();
		} else if (type == utils::LIST_PRODUCT) {
			listProducts();
		} else if (type == utils::PRODUCT_IMAGE) {
			listProductImages(splitRequest);
		} else if (type == utils::STOCK_GENERAL) {
			listStockGeneral(splitRequest);
		} else if (type == utils::STOCK_AREA) {
			listStockArea(splitRequest);
		} else if (type == utils::STOCK_HISTORIC) {
			listStockHistoric(splitRequest);
		} else if (type == utils::PROCESS_FILE) {
			processFile(splitRequest);
		} else if (type == utils::PROCESS_VIDEO) {
			processVideo(splitRequest);
		} else if (type == utils::QUIT) {
			this->stop();
		} else if (type == utils::DETAILS_AREA){
			getAreas();
		}
		else if (type == utils::DETAILS_PRODUCT){
					detallesProductos();
				}
		else if (type == utils::IMAGES){
					imagenesDeProducto(splitRequest);
				}
		else {
			this->socket->send(utils::ERROR_MESSAGE);
		}
	}
}
Exemple #5
0
void Cage::applyWave()
{
    bool isCenter = false;
    float cx = 0;
    float cy = 0;
    Areas &areas = getAreas(0);
    if (areas.size()>0) {
        cx = areas.at(0).pt[0];
        cy = areas.at(0).pt[1];
        isCenter = true;
    }

    for (unsigned int i=0; i<areas.size(); i++) {
        Area &area = areas.at(i);
        cx = (cx + area.pt[0])/2.0;
        cy = (cy + area.pt[1])/2.0;
    }

    if (isCenter) {
        if (isCenterPrev) {
            if (isWaveDebug) {
                color(1,0,0);
                lineWidth(10);
                line(cxPrev, cyPrev, cx, cy);
            }

            if (isWave) {
                Wave wave;
                wave.x = cx;
                wave.y = cy;
                wave.angle = angle(cxPrev, cyPrev, cx, cy);
                wave.lenght = distance(cxPrev, cyPrev, cx, cy)*waveForce;
                waves.append(wave);
            }
        }
        isCenterPrev = true;
    }
    else {
        isCenterPrev = false;
    }
    cxPrev = cx;
    cyPrev = cy;
    QList<Wave>::iterator i= waves.begin();
    while (i != waves.end()) {
        Wave &wave = *i;
        if (wave.lenght > 0) {
            wave.lenght -= waveSpeed;
            wave.x += waveSpeed*cos(wave.angle);
            wave.y += waveSpeed*sin(wave.angle);

            if (isWave) {
                int x1 = (wave.x - waveWidth/2.0)/cellSize;
                int y1 = (wave.y - waveWidth/2.0)/cellSize;

                int x2 = (wave.x + waveWidth/2.0)/cellSize;
                int y2 = (wave.y + waveWidth/2.0)/cellSize;

                zeroMatrix(x1, y1, x2, y2);
            }

            i++;
        }
        else {
            i = waves.erase(i);
        }
    }

}