コード例 #1
0
ファイル: ofxUeye.cpp プロジェクト: paulobarcelos/ofxUeye
//////////////////////////////////////////////////////////////////////////////////
// listDevices -------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////
void ofxUeye::listDevices(){
	// At least one camera must be available
	INT nNumCam;
	if( is_GetNumberOfCameras( &nNumCam ) == IS_SUCCESS)
	{
		if( nNumCam >= 1 )
		{
			// Create new list with suitable size
			UEYE_CAMERA_LIST* pucl;
			pucl = (UEYE_CAMERA_LIST*) new char [sizeof (DWORD)
			+ nNumCam
			* sizeof (UEYE_CAMERA_INFO)];
			pucl->dwCount = nNumCam;
 
			//Retrieve camera info
			if (is_GetCameraList(pucl) == IS_SUCCESS)
			{
				int iCamera;
				printf("---------------------------------\n");
				printf("ofxUeye - listDevices:\n");
				for (iCamera = 0; iCamera < (int)pucl->dwCount; iCamera++)
				{
					printf("    Camera %i Id: %d\n", iCamera, pucl->uci[iCamera].dwCameraID);
				}
				printf("---------------------------------\n");
			}
			delete [] pucl;
		}
	}
}
コード例 #2
0
INT WINAPI GetCameraNames(UEYE_CAMERA_LIST* pCameraList) {
	INT nNumCam = 0;
	INT result = is_GetNumberOfCameras( &nNumCam );
	if(result == IS_SUCCESS) {
		pCameraList->dwCount = nNumCam;
		// At least one camera must be available
		if (nNumCam >= 1) {
			result |= is_GetCameraList(pCameraList);
			// Camera found
			TRACE("Camera models found %s\n", pCameraList->uci->Model);
		}
	} 	
	return result;
}
コード例 #3
0
bool IdsSourceSink::Init()
{

    PUEYE_CAMERA_LIST m_pCamList;
    UEYE_CAMERA_INFO m_CameraInfo;
    // init the internal camera info structure
    ZeroMemory (&m_CameraInfo, sizeof(UEYE_CAMERA_INFO));

    // get the cameralist from SDK
    m_pCamList = new UEYE_CAMERA_LIST;
    m_pCamList->dwCount = 0;

    if (is_GetCameraList (m_pCamList) == IS_SUCCESS) {
            DWORD dw = m_pCamList->dwCount;
            delete m_pCamList;

            // Reallocate the required camera list size
            m_pCamList = (PUEYE_CAMERA_LIST)new char[sizeof(DWORD) + dw * sizeof(UEYE_CAMERA_INFO)];
            m_pCamList->dwCount = dw;

            // Get CameraList and store it ...
            if (is_GetCameraList (m_pCamList) != IS_SUCCESS) return false;
    } else return false;

    if (m_pCamList->dwCount==0) {
        qDebug()<<"No camera found";
        return false;
    } else if (m_pCamList->dwCount>1) {
        qDebug()<<"More than 1 camera: "<<m_pCamList->dwCount;
    }

    // will use camera 0
    memcpy (&m_CameraInfo, &m_pCamList->uci[0], sizeof(UEYE_CAMERA_INFO));
    hCam = (HIDS) (m_CameraInfo.dwDeviceID | IS_USE_DEVICE_ID);


    if(is_InitCamera (&hCam, NULL)!= IS_SUCCESS){
        qDebug()<<"init not successful";
           return false;
    }

//    double minFPS, maxFPS, FPSinterval;
//    is_GetFrameTimeRange (hCam, &minFPS, &maxFPS, &FPSinterval);
         //cout<< fixed << setprecision(4) << minFPS << " MINFPS " << maxFPS << " MAXFPS "<< FPSinterval << " FPSinterval " << endl;
         //myfile<< fixed << setprecision(4) << minFPS << " MINFPS " << maxFPS << " MAXFPS "<< FPSinterval << " FPSinterval " << endl;

    is_SetGainBoost (hCam, IS_SET_GAINBOOST_OFF);
    is_SetWhiteBalance (hCam, IS_SET_WB_DISABLE);
//    is_SetBrightness (hCam,0);
//    is_SetContrast (hCam,0);
//    is_SetGamma (hCam, 100);// Value multiplied by 100 (for the camera it goes from 0.01 to 10
    is_SetHWGainFactor (hCam, IS_SET_MASTER_GAIN_FACTOR, 100);
    uint pixelC=304;
    is_PixelClock(hCam, IS_PIXELCLOCK_CMD_SET, (void*)&pixelC, sizeof(pixelC));

    flagIDS= is_SetSubSampling (hCam, IS_SUBSAMPLING_2X_VERTICAL | IS_SUBSAMPLING_2X_HORIZONTAL); //Both are needed

    //Configuration section: very important to match the img_bpp=8 with the chacracteristics of the CV::MAT image to use
    //weird results like cropping or black lines can be obtained if not changed accordingly
    int img_width=2048, img_height=2048, img_bpp=8, factorSMP=2; //Variable to state the Linehopping
//    int img_step, img_data_size;

    imgMem = NULL;
    is_AllocImageMem(hCam, img_width/factorSMP, img_height/factorSMP, img_bpp, &imgMem, &memId);
    is_SetImageMem (hCam, imgMem, memId);
//    is_SetImageSize (hCam, img_width/factorSMP, img_height/factorSMP);

    is_SetColorMode (hCam, IS_CM_MONO8);

    is_SetDisplayMode (hCam, IS_SET_DM_DIB); // Direct buffer mode writes to RAM which is the only option on Linux

    //OpenCV variables: REMEMBER THE SUBSAMPLING
    buffer=cv::Mat::zeros(img_width/factorSMP,img_height/factorSMP, CV_8UC1);

    return true;
}
コード例 #4
0
ファイル: uEyeCapture.cpp プロジェクト: Aldrog/corecvs
UEyeCaptureInterface::UEyeCaptureInterface(string _devname) :
    sync(NO_SYNC),
    currentLeft(NULL),
    currentRight(NULL),
    spin(this)
{
    printf("#################################################   \n");
    printf("Hi, Stranger. I will help you with the uEye cameras.\n");
    printf("Remember, everything is in the eye of the beholder. \n");
    printf("#################################################   \n");
    int camNum = 0;
    is_GetNumberOfCameras (&camNum);
    printf("Currently there are %d cameras in the system:\n", camNum);
    UEYE_CAMERA_LIST *camList = (UEYE_CAMERA_LIST *)malloc(sizeof(ULONG) + camNum * sizeof(UEYE_CAMERA_INFO));
    camList->dwCount = camNum;
    is_GetCameraList(camList);

    printf("%2s %16s %5s %5s %5s %6s %16s\n",
            "N", "Model" ,"camId", "devId" ,"sensId", "inuse?", "Serial");

    for (int i = 0; i < camNum; i++)
    {
        printf("% 2d %16s % 5u % 5u %5u %6s %16s\n",
            i,
            camList->uci[i].Model,
            camList->uci[i].dwCameraID,
            camList->uci[i].dwDeviceID,
            camList->uci[i].dwSensorID,
            camList->uci[i].dwInUse != 0 ? "used" : "free",
            camList->uci[i].SerNo);

    }
    free(camList);


    this->devname = _devname;

    //     Group Number                   1       2 3        4 5          6 7             8 910   11     12 13     14 15                 16 17
    QRegExp deviceStringPattern(QString("^([^,:]*)(,([^:]*))?(:(\\d*)mhz)?(:([0-9.]*)fps)?(:((10)|(8))b)?(:x(\\d*))?(:(sync|hsync|fsync|esync))?(:(global))?$"));
    static const int Device1Group       = 1;
    static const int Device2Group       = 3;
    static const int PixelClockGroup    = 5;
    static const int FpsGroup           = 7;
    static const int BitsGroup          = 9;
    static const int BinningGroup       = 13;
    static const int SyncGroup          = 15;
    static const int GlobalShutterGroup = 17;

    //static const int WidthGroup       = 12;
    //static const int HeightGroup      = 13;

    printf ("Input string %s\n", _devname.c_str());
    QString qdevname(_devname.c_str());
    int result = deviceStringPattern.indexIn(qdevname);
    if (result == -1)
    {
        printf("Error in device string format:%s\n", _devname.c_str());
        exit(EXIT_FAILURE);
    }
    printf (
        "Parsed data:\n"
        "  | - Device 1=%s\n"
        "  | - Device 2=%s\n"
        "  | - Pixelclock %s Mhz, FPS %s\n"
        "  | - BPP:%s with bining %s\n"
        "  | - Sync:%s\n"
        "  \\ - GlobalShutter:%s\n",

        deviceStringPattern.cap(Device1Group).toLatin1().constData(),
        deviceStringPattern.cap(Device2Group).toLatin1().constData(),
        deviceStringPattern.cap(PixelClockGroup).toLatin1().constData(),
        deviceStringPattern.cap(FpsGroup).toLatin1().constData(),
        deviceStringPattern.cap(BitsGroup).toLatin1().constData(),
        deviceStringPattern.cap(BinningGroup).toLatin1().constData(),
        deviceStringPattern.cap(SyncGroup).toLatin1().constData(),
        deviceStringPattern.cap(GlobalShutterGroup).toLatin1().constData()
    );

    string leftName  = deviceStringPattern.cap(Device1Group).toLatin1().constData();
    string rightName = deviceStringPattern.cap(Device2Group).toLatin1().constData();
    bool err;

    int leftID =  deviceStringPattern.cap(Device1Group).toInt(&err);
    if (!err) {
        printf("Wrong left device ID (%s)\n", leftName.c_str());
    }

    int rightID =  deviceStringPattern.cap(Device2Group).toInt(&err);
    if (!err) {
        printf("Wrong right device ID (%s)\n", rightName.c_str());
    }

    int pixelClock = deviceStringPattern.cap(PixelClockGroup).toInt(&err);
    if (!err) pixelClock = 85;

    double fps = deviceStringPattern.cap(FpsGroup).toDouble(&err);
    if (!err) fps = 50.0;


/*    int width = deviceStringPattern.cap(WidthGroup).toInt(&err);
    if (!err || width <= 0) width = 800;

    int height = deviceStringPattern.cap(HeightGroup).toInt(&err);
    if (!err || height <= 0) height = 600;*/


    int binning = 1;
    binning = deviceStringPattern.cap(BinningGroup).toInt(&err);
    if (!err) binning = 1;

    sync = NO_SYNC;

    if (!deviceStringPattern.cap(SyncGroup).compare(QString("sync")))
        sync = SOFT_SYNC;

    if (!deviceStringPattern.cap(SyncGroup).compare(QString("hsync")))
        sync = HARD_SYNC;

    if (!deviceStringPattern.cap(SyncGroup).compare(QString("fsync")))
        sync = FRAME_HARD_SYNC;

    if (!deviceStringPattern.cap(SyncGroup).compare(QString("esync")))
        sync = EXT_SYNC;


    bool  globalShutter = false;
    if (!deviceStringPattern.cap(GlobalShutterGroup).compare(QString("global")))
        globalShutter = true;

    printf("Shutter is:%s\n", globalShutter ? "global" : "rolling");

    printf("Capture Left  device: GigE DeviceID = %d\n", leftID);
    printf("Capture Right device: GigE DeviceID = %d\n", rightID);

    leftCamera.init(leftID, (binning == 2), globalShutter, pixelClock, fps);
    rightCamera.init(rightID, (binning == 2), globalShutter, pixelClock, fps);

    skippedCount = 0;
    triggerSkippedCount = 0;
    frameDelay = 0;
}