예제 #1
0
void Scene::on_render_end(const Project& project)
{
    for (each<CameraContainer> i = cameras(); i; ++i)
        i->on_render_end(project);

    m_has_render_data = false;
}
예제 #2
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //QString path = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + "/PlanktonTracker/";

    ui->delayLineEdit->setEnabled(false);
    ui->numPhotoLineEdit->setEnabled(false);
    ui->startButton->setEnabled(false);
    ui->stopButton->setEnabled(false);
    ui->trackButton->setEnabled(false);

    Pylon::PylonAutoInitTerm autoInitTerm;

    QActionGroup *cameraDevicesGroup = new QActionGroup(this);
    cameraDevicesGroup->setExclusive(true);

    try {

        CTlFactory& tlFactory = CTlFactory::GetInstance();

        // Get all attached devices.
        DeviceInfoList_t devices;
        if (tlFactory.EnumerateDevices(devices) == 0) {
            QString status = QString("No camera present.");
            ui->statusBar->showMessage(status);
        }

        // Create an array of instant cameras for the found devices and avoid exceeding a maximum number of devices.
        CInstantCameraArray cameras(min(devices.size(), c_maxCamerasToSee));

        for (size_t i = 0; i < cameras.GetSize(); ++i) {

            cameras[i].Attach(tlFactory.CreateDevice(devices[i]));

            QAction *cameraDeviceAction = new QAction((QString)cameras[i].GetDeviceInfo().GetModelName(), cameraDevicesGroup);
            cameraDeviceAction->setCheckable(true);
            cameraDeviceAction->setData(QVariant::fromValue(cameras[i].GetDeviceInfo()));
            if (i == 0) {
                cameraDeviceAction->setChecked(true);
                // Set as default camera and enable some UI elements
                if (setCamera(cameras[i].GetDeviceInfo())) {
                    ui->delayLineEdit->setEnabled(true);
                    ui->numPhotoLineEdit->setEnabled(true);
                    ui->startButton->setEnabled(true);
                }
            }
            ui->menuCamera->addAction(cameraDeviceAction);

        }

    } catch (GenICam::GenericException &e) {
        QString status = QString("An exception occurred: %1").arg((QString)e.GetDescription());
        ui->statusBar->showMessage(status);
    }

    connect(cameraDevicesGroup, SIGNAL(triggered(QAction*)), SLOT(updateCameraDevice(QAction*)));

}
예제 #3
0
GigaCamera::GigaCamera()
{
    //初始化相机运行时环境
    Pylon::PylonAutoInitTerm autoInitTerm;
    try
    {
        //find usable cameras
        CTlFactory& tlFactory = CTlFactory::GetInstance();
        IGigETransportLayer *pTL = dynamic_cast<IGigETransportLayer*>(tlFactory.CreateTl(BaslerGigEDeviceClass));
        if(pTL == NULL)
        {
            throw RUNTIME_EXCEPTION;
        }
        DeviceInfoList_t allDeviceInfos;
        if(pTL->EnumerateDevices(allDeviceInfos) == 0)
        {
            throw RUNTIME_EXCEPTION;
        }
        //将找到的相机放入可用相机数组
        usableDeviceInfos.push_back(allDeviceInfos[0]);
        const String_t subnet(static_cast<const CBaslerGigEDeviceInfo&>(allDeviceInfos[0]).GetSubnetAddress());
        for(size_t i=1;i<allDeviceInfos.size()&&usableDeviceInfos.size()<c_maxCamerasToUse;i++)
        {
            const CBaslerGigEDeviceInfo& gigeinfo=static_cast<const CBaslerGigEDeviceInfo&>(allDeviceInfos[i]);
            if(subnet==gigeinfo.GetSubnetAddress())
            {
                //将找到的可用相机的子网信息放入usableDeviceInfos中
                usableDeviceInfos.push_back(gigeinfo);
            }
            else
            {
                //error info

            }
        }

        cameras(usableDeviceInfos.size());

        for(size_t i=0;i<cameras.GetSize();i++)
        {
            //利用得到的可用相机设别实例化相机,放在cameras中
            cameras[i].Attach(tlFactory.CreateDevice(usableDeviceInfos[i]));
            //cameras[i].RegisterConfiguration(new CActionTriggerConfiguration(DeviceKey,));
            //相机上下文信息,即给相机编号,与获取到的图像信息对应
            cameras[i].SetCameraContext(i);

        }
    }
    catch(GenICam::GenericException &e)
    {
        //异常信息
        qDebug()<<e.GetDescription();

    }

}
예제 #4
0
void Scene::update_asset_paths(const StringDictionary& mappings)
{
    BaseGroup::update_asset_paths(mappings);

    do_update_asset_paths(mappings, cameras());

    if (impl->m_environment.get())
        impl->m_environment->update_asset_paths(mappings);

    do_update_asset_paths(mappings, environment_edfs());
    do_update_asset_paths(mappings, environment_shaders());
}
예제 #5
0
void Scene::collect_asset_paths(StringArray& paths) const
{
    BaseGroup::collect_asset_paths(paths);

    do_collect_asset_paths(paths, cameras());

    if (impl->m_environment.get())
        impl->m_environment->collect_asset_paths(paths);

    do_collect_asset_paths(paths, environment_edfs());
    do_collect_asset_paths(paths, environment_shaders());
}
예제 #6
0
bool Scene::on_render_begin(
    const Project&          project,
    IAbortSwitch*           abort_switch)
{
    bool success = true;

    create_render_data();

    for (each<CameraContainer> i = cameras(); i; ++i)
        success = success && i->on_render_begin(project, abort_switch);

    return success;
}
예제 #7
0
bool Scene::on_frame_begin(
    const Project&          project,
    const BaseGroup*        parent,
    OnFrameBeginRecorder&   recorder,
    IAbortSwitch*           abort_switch)
{
    if (!Entity::on_frame_begin(project, parent, recorder, abort_switch))
        return false;

    m_camera = project.get_uncached_active_camera();

    // Fail if we don't have a camera.
    if (m_camera == 0)
    {
        RENDERER_LOG_ERROR("no cameras in scene or no camera specified in the frame entity.");
        return false;
    }

    bool success = true;

    success = success && impl->m_default_surface_shader->on_frame_begin(project, this, recorder, abort_switch);

    success = success && invoke_on_frame_begin(project, this, colors(), recorder, abort_switch);
    success = success && invoke_on_frame_begin(project, this, textures(), recorder, abort_switch);
    success = success && invoke_on_frame_begin(project, this, texture_instances(), recorder, abort_switch);
    success = success && invoke_on_frame_begin(project, this, shader_groups(), recorder, abort_switch);

    success = success && invoke_on_frame_begin(project, this, cameras(), recorder, abort_switch);
    success = success && invoke_on_frame_begin(project, this, environment_edfs(), recorder, abort_switch);
    success = success && invoke_on_frame_begin(project, this, environment_shaders(), recorder, abort_switch);

    if (!is_aborted(abort_switch) && impl->m_environment.get())
        success = success && impl->m_environment->on_frame_begin(project, this, recorder, abort_switch);

    success = success && invoke_on_frame_begin(project, this, assemblies(), recorder, abort_switch);
    success = success && invoke_on_frame_begin(project, this, assembly_instances(), recorder, abort_switch);

    return success;
}
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{       
    
    // Initiatlize Pylon
    Pylon::PylonAutoInitTerm auto_init_term;

    try
    {
        // Get the transport layer factory.
        Pylon::CTlFactory& tlFactory = Pylon::CTlFactory::GetInstance();
        
        // Get all attached devices
        Pylon::DeviceInfoList_t devices;
        tlFactory.EnumerateDevices(devices);

        
        // Create an array of instant cameras for the found devices
        Pylon::CInstantCameraArray cameras(devices.size());

        // Init output
        plhs[0] = mxCreateCellMatrix(cameras.GetSize(),2);
        
        // Find all names
        for(size_t i = 0; i < cameras.GetSize(); ++i)
        {
            cameras[i].Attach(tlFactory.CreateDevice(devices[i]));
            mxSetCell(plhs[0],i+cameras.GetSize(),mxCreateString(cameras[i].GetDeviceInfo().GetModelName()));
            mxSetCell(plhs[0],i,mxCreateDoubleScalar(i));
        }
        
    }
    catch (GenICam::GenericException &e)
    {
        // Error handling.
        mexErrMsgIdAndTxt("baslerDriver:Error:CameraError",e.GetDescription());
    }
    
    return;
}