/// /// @return Returns the value of m_inited after initialization, e.g. returns TRUE if the camera is successfully initialized /// bool SimpleDirectShowAcq::Open() { struct SimpleCapParams params; bool success = false; if (m_width == 0 || m_height == 0) // these get set in Init() { m_logMsg = "Unable to Open camera: width and height are not set."; } else { m_numCameras = setupESCAPI(); if (m_numCameras == 0) { m_logMsg.Format("%s: no cameras found.\n", __FUNCTION__); } else { params.mWidth = m_width; params.mHeight = m_height; params.mTargetBuf = (int *)m_buf; // m_buf gets set in Init() m_cameraIndex = 0; if (initCapture(m_cameraIndex, ¶ms)) { m_inited = true; // assigning it here avoids an annoying compiler warning } } } return m_inited; }
VREP_DLLEXPORT unsigned char v_repStart(void* reservedPointer,int reservedInt) { // This is called just once, at the start of V-REP // Dynamically load and bind V-REP functions: char curDirAndFile[1024]; GetModuleFileName(NULL,curDirAndFile,1023); PathRemoveFileSpec(curDirAndFile); std::string currentDirAndPath(curDirAndFile); std::string temp(currentDirAndPath); temp+="\\v_rep.dll"; vrepLib=loadVrepLibrary(temp.c_str()); if (vrepLib==NULL) { std::cout << "Error, could not find or correctly load v_rep.dll. Cannot start 'Cam' plugin.\n"; return(0); // Means error, V-REP will unload this plugin } if (getVrepProcAddresses(vrepLib)==0) { std::cout << "Error, could not find all required functions in v_rep.dll. Cannot start 'Cam' plugin.\n"; unloadVrepLibrary(vrepLib); return(0); // Means error, V-REP will unload this plugin } int vrepVer; simGetIntegerParameter(sim_intparam_program_version,&vrepVer); if (vrepVer<20600) // if V-REP version is smaller than 2.06.00 { std::cout << "Sorry, your V-REP copy is somewhat old, V-REP 2.6.0 or later is required. Cannot start 'Cam' plugin.\n"; unloadVrepLibrary(vrepLib); return(0); // initialization failed!! } // Marc modified following function to return a neg. value in case of initialization error: deviceCount=setupESCAPI(); if (deviceCount<0) { std::cout << "ESCAPI initialization failed (error code: " << deviceCount << "). Is 'escapi.dll' available? Cannot start 'Cam' plugin.\n"; unloadVrepLibrary(vrepLib); return(0); // initialization failed!! } // Register one new Lua command: int inArgs1[]={3,sim_lua_arg_int,sim_lua_arg_int,sim_lua_arg_int}; simRegisterCustomLuaFunction(LUA_START,strConCat("number result,number resX,number resY=",LUA_START,"(number deviceIndex,number resX,number resY)"),inArgs1,LUA_START_CALLBACK); int inArgs2[]={1,sim_lua_arg_int}; simRegisterCustomLuaFunction(LUA_END,strConCat("number result=",LUA_END,"(number deviceIndex)"),inArgs2,LUA_END_CALLBACK); simRegisterCustomLuaFunction(LUA_INFO,strConCat("string info=",LUA_INFO,"(number index)"),inArgs2,LUA_INFO_CALLBACK); int inArgs5[]={2,sim_lua_arg_int,sim_lua_arg_int}; simRegisterCustomLuaFunction(LUA_GRAB,strConCat("number result=",LUA_GRAB,"(number index,number visionSensorHandle)"),inArgs5,LUA_GRAB_CALLBACK); InitializeCriticalSection(&m_cs); return(3); // initialization went fine, return the version number of this extension module (can be queried with simGetModuleName) // version 1 was for V-REP versions before V-REP 2.5.12 // version 2 was for V-REP versions before V-REP 2.6.0 }
void main() { int devices = setupESCAPI(); if (devices == 0) { printf("ESCAPI initialization failure or no devices found.\n"); return; } int i; for (i = 0; i < devices; i++) { char temp[256]; getCaptureDeviceName(i, temp, 256); printf("Device %d: \"%s\"\n", i, temp); } }