示例#1
0
/*
Регистрация нового устройства на шине SPI
возвращает DevId не требует захвата устройства
Параметры:
port   - номер порта SPI
DevOn  - адрес функции для выбора устройства
DevOff - адрес функции для освобождения устройства
*/
BYTE SPI_RegDevice(BYTE port, BYTE Mode, DWORD Speed, void* DevOn,void* DevOff)
{   
    //ищем свободный элемент массива 
    BYTE i;    
    BYTE j; 
    if((DevOn==0)||(DevOff==0)) return 2;//неправильные функции выбора устройства
    for(i=0;i<SPI_DEV_COUNT;i++){
        if(SPI_Devices[i].Status==0){
            SPI_Devices[i].Port=port;
            SPI_Devices[i].Status = SPI_DEV_ACTIVE;
            SPI_Devices[i].DevSelect = DevOn;
		    SPI_Devices[i].DevDeselect = DevOff;  
		    SPI_Devices[i].SPIParams = (GetPrescale(Speed)&0x001F) ;
		    Call_Dev(SPI_Devices[i].DevDeselect);
		    if(Mode&0x01){
    		    SPI_Devices[i].SPIParams|=SPI_CLK_POLAR_H;    		    
		    }
		    if(Mode&0x02){
    		    SPI_Devices[i].SPIParams|=SPI_CLK_EDGE_HL;
		    }		    
            return 0; //завершено успешно
        }         
    }
    return 1; // нет свободных сокетов для устройства
}
示例#2
0
Shape Mod::ModSearch_(            // returns coords of the facial landmarks
        const Shape& startshape,  // in: startshape roughly positioned on face
        const Image& img,         // in: grayscale image (typically just ROI)
        const Shape* pinnedshape) // in: pinned landmarks, NULL if nothing pinned
const
{
    Image scaledimg;         // image scaled to fixed eye-mouth distance
    const double imgscale = GetPrescale(startshape);

    // TODO This resize is quite slow (cv::INTER_NEAREST is even slower, why?).
    cv::resize(img, scaledimg,
               cv::Size(), imgscale, imgscale, cv::INTER_LINEAR);

    TraceShape(startshape * imgscale, scaledimg, 0, -1, "start");

    vector<Image> pyr;       // image pyramid (a vec of images, one for each pyr lev)
    CreatePyr(pyr, scaledimg, N_PYR_LEVS);

    Shape shape(startshape * imgscale * GetPyrScale(N_PYR_LEVS));

    Shape pinned;            // pinnedshape scaled to current pyr lev
    if (pinnedshape)
        pinned = *pinnedshape * imgscale * GetPyrScale(N_PYR_LEVS);

    for (int ilev = N_PYR_LEVS-1; ilev >= 0; ilev--)
    {
        shape  *= PYR_RATIO; // scale shape to this pyr lev
        pinned *= PYR_RATIO;

        LevSearch_(shape,
                   ilev, pyr[ilev], pinned);
    }
    return shape / imgscale;
}