Example #1
0
RETURN_CODE __uservice::start()
{
    if (__check_ctrlEnabled(START))
    {
        if (!isRunning())
        {
            if (!isInit())
                init();

            if (isInit())
            {
                console() << MSG__START << this << "...\n";

                // REF I130428-1
                if (__D_start() == RC_SUCCESS)
                {
                    Runable::start();
                    return RC_SUCCESS;
                }
            }
        }

        warning(this, W__ALREADY_RUNNING);
        return RC_FAILURE;
    }

    return RC_SUCCESS;
}
Example #2
0
int VideoSaverFlyCapture::startCapture() {

  if (!isFlyCapture()) {
    return VideoSaver::startCapture();
    
  } else {

  
    if ((isFinished()) && (isInit()) && (!isCapturing())) {
      // start thread to begin capture and populate Mat frame
      FlyCapture2::Error error = m_Camera.StartCapture();
      if ( error == FlyCapture2::PGRERROR_ISOCH_BANDWIDTH_EXCEEDED )
      {
	std::cout << "Bandwidth exceeded" << std::endl;     
	return -1;
      }
      else if ( error != FlyCapture2::PGRERROR_OK )
      {
	std::cout << "Failed to start image capture" << std::endl;     
	return -1;
      } 
    
    
      //start the grabbing thread
      m_KeepWritingAlive = false;  // not to be started
      m_WritingFinished = true;
      m_newFrameAvailable = false;
      std::cout <<  "Start video grabbing .." << std::endl;

      m_captureThread = new std::thread(&VideoSaverFlyCapture::captureThread,this);

      m_capturing = true;

      sleep(500);
      waitForNewFrame();

      return 0;

    } else {
      if (isInit()) {
	std::cout << "Warning: capture not yet finished !" << std::endl;    
      } else {
	std::cout << "Warning: camera not available!" << std::endl;    
      }
      return -1;    
    } 
  }
}
void CameraHandler::downSample(int sampling_ratio)
{
  if (!isInit()) return;

  _cam_param.imsize.cols /= sampling_ratio;
  _cam_param.imsize.rows /= sampling_ratio;

  _cam_param.K /= sampling_ratio;
  _cam_param.K.at<float>(2,2) = 1;
  _cam_param.K_inv = _cam_param.K.inv();

  if (!_frame.empty())
    cv::resize(_frame, _frame, cv::Size(),
               1.0/sampling_ratio, 1.0/sampling_ratio);

  if (!_mask.empty())
    cv::resize(_mask, _mask, cv::Size(),
               1.0/sampling_ratio, 1.0/sampling_ratio);

  if (!_LUT_sphere.empty())
    im2Sph(_cam_param.imsize.rows, _cam_param.imsize.cols);

  _is_sampled = true;
  _sampling_ratio = sampling_ratio;
}
void CameraHandler::im2Sph(int rows, int cols)
{
  if (!isInit()) return;

  if (_mask.empty())
    _mask = cv::Mat::ones(rows, cols, CV_8UC1);

  cv::Mat ind_nzero;
  cv::findNonZero(_mask, ind_nzero);
  int pixel_count = ind_nzero.rows * ind_nzero.cols;

  _LUT_sphere = cv::Mat::zeros(3, pixel_count, CV_32FC1);

  int i = 0;
  for (int row = 0; row < rows; ++row)
  {
    for (int col = 0; col < cols; ++col)
    {
      if (!(_mask.at<uchar>(row, col) == 0))
      {
        cv::Vec3f pts_sph = pix2Sph(row, col);

        _LUT_sphere.at<float>(0, i) = pts_sph[0];
        _LUT_sphere.at<float>(1, i) = pts_sph[1];
        _LUT_sphere.at<float>(2, i) = pts_sph[2];
      }
      ++i;
    }
  }

  // Apply pose rotation
  _LUT_sphere = _cam_param.cam_pose(cv::Rect(0,0,3,3)) * _LUT_sphere;

  _sphLUT_init = true;
}
Example #5
0
/** @brief getThread
  * get the thread ascociated with an index
  * @param index the index of the thread to get
  * @return a handle on the thread you are getting
  */
ThreadHandle Threadler::getThread(const ThreadID_t & index)
{
	if (!isInit())
		return ThreadHandle();

	return get()->m_threads[index];
}
CWordManager::~CWordManager()
{
	if (isInit() != NULL) 
	{
		DisconnectWordEventHandler();
		m_WordLoader.Release();
	}

	// kody - ulozeni Wordovskejch stylu do XML
	CDirectoriesManager & m = ((CReportAsistentApp *) AfxGetApp())->m_pGeneralManager->DirectoriesManager;
	
	BOOL res = FALSE;
	
	try
	{
		res = saveStylesToXML((LPCTSTR) m.getWordStylesConfigFilePath());
	}
	catch(...)
	{
		res = FALSE;
	}

	if(!res)
		CReportAsistentApp::ReportError(IDS_STYLLISTSAVE_ERR);
}
Example #7
0
void SharedObject::makeUnique(std::map<SharedObjectNode*, SharedObject>& already_copied,
                              bool clone_members) {
  if (node && node->count>1) {
    // First find out if the expression has already been copied
    std::map<SharedObjectNode*, SharedObject>::iterator it = already_copied.find(node);

    if (it==already_copied.end()) {
      // If the expression has not yet been copied
      SharedObjectNode *newnode = node->clone();

      // Copy the data members
      if (clone_members) newnode->deepCopyMembers(already_copied);

      // Initialize object if parent was initialized
      if (isInit() && !newnode->is_init_) {
        newnode->init();
      }

      // Assign cloned node to object
      assignNode(newnode);
    } else {
      // Use an existing copy
      assignNode(it->second.get());
    }
  }
}
Example #8
0
/** @brief depth
  *	accessthe depth of the render volume
  * @return depth
  */
unsigned int Renderer::depth()
{
	if (!isInit())
		return 0;

	return get()->m_depth;
}
Example #9
0
/** @brief isSetup
  * access if the module has been set up
  * @return true if set up
  */
bool Renderer::isSetup()
{
	if (!isInit())
		return false;

	return get()->m_isSetup;
}
Example #10
0
File: fx.cpp Project: kozatt/casadi
vector<SXMatrix> FX::evalSX(const vector<SXMatrix>& arg){
  casadi_assert_message(isInit(),"Function has not been initialized");
  
  // Copy the arguments into a new vector with the right sparsity
  casadi_assert_message(arg.size()<=getNumInputs(), "FX::evalSX: number of passed-in dependencies (" << arg.size() << ") should not exceed the number of inputs of the function (" << getNumInputs() << ").");
  vector<SXMatrix> arg2 = arg;
  arg2.resize(getNumInputs());
  for(int iind=0; iind<arg.size(); ++iind){
    // If sparsities do not match, we need to map the nonzeros onto the new pattern
    if(!(arg2[iind].sparsity()==input(iind).sparsity())){
      arg2[iind] = project(arg2[iind],input(iind).sparsity());
    }
  }

  // Create result vector with correct sparsity for the result
  vector<SXMatrix> res(getNumOutputs());
  for(int i=0; i<res.size(); ++i){
    res[i] = SXMatrix(output(i).sparsity());
  }
  
  // No sensitivities
  vector<vector<SXMatrix> > dummy;
  
  // Evaluate the algorithm
  (*this)->evalSX(arg2,res,dummy,dummy,dummy,dummy,false);
  
  // Return the result
  return res;
}
void CWordManager::OpenWordEditor()
{
	if (! isInit()) 
	{
		if (! InitWordLoader()) return;
	}



	try
	{
		WordEditHideMainWindow();


		SetWordEditorParentTaskName();
		m_WordLoader->PutstrDefaultWordTemplate(getWordTemplate());			
		m_WordLoader->OpenWordEditor();
	}
	catch (_com_error e)
	{
		m_WordLoader = NULL;
		WordEditShowMainWindow();
		CReportAsistentApp::ReportError(IDS_LMRA_WORLOADER_CONNECTON_FAILED, (LPCTSTR) e.ErrorMessage());			
	}
}
Example #12
0
namespace Charset {

static const AutoPtr<ICharset> StandardCharsets::ISO_8859_1;

static const AutoPtr<ICharset> StandardCharsets::US_ASCII;

static const AutoPtr<ICharset> StandardCharsets::UTF_8;

static const AutoPtr<ICharset> StandardCharsets::UTF_16;

static const AutoPtr<ICharset> StandardCharsets::UTF_16BE;

static const AutoPtr<ICharset> StandardCharsets::UTF_16LE;

StandardCharsets::StandardCharsets()
{}

Boolean StandardCharsets::isInit()
{
    Charset::ForName(String("ISO-8859-1"), (ICharset**)&ISO_8859_1);
    Charset::ForName(String("US-ASCII"), (ICharset**)&US_ASCII);
    Charset::ForName(String("UTF-8"), (ICharset**)&UTF_8);
    Charset::ForName(String("UTF-16"), (ICharset**)&UTF_16);
    Charset::ForName(String("UTF-16BE"), (ICharset**)&UTF_16BE);
    Charset::ForName(String("UTF-16LE"), (ICharset**)&UTF_16LE);
    return TRUE;
}

Boolean StandardCharsets::isinitflag = isInit();

} // namespace Charset
void CWordManager::SetWordEditorParentTaskName()
{
	ASSERT(isInit());

	CString wdCaption;
	AfxGetApp()->GetMainWnd()->GetWindowText(wdCaption);
	m_WordLoader->PutstrParentTaskName((LPCTSTR) wdCaption);
}
Example #14
0
int CCmd::help(int cmdid)
{
	if(INIT_COMPLETE==isInit(cmdid)){
		//printf("commandid=%02d\t",cmdid);
		pCmdCallback[cmdid]->help(cmdid);
	}
	return NULL;
}
Example #15
0
/** @brief clear
  * clear all references to render objects
  * @return true on success
  */
bool Renderer::clear()
{
	if (!isInit())
		return false;

	get()->m_objects.clear();

	return true;
}
	void Input::setResizing(const cv::Size& resizing)
	{
		if (isInit()) {
			WARN << "already init, cannot change resizing any longer" << ENDL;
			return;
		}

		m_resizing = resizing;
	}
Example #17
0
/** @brief destroy
  * destroy the singleton
  * @return true on success
  */
bool Renderer::destroy()
{
	if(!isInit())
		return false;
	if (!clear())
		return false;

	return Singleton<Renderer>::destroy();
}
Example #18
0
/** @brief getRenderObject
  * get the render object associated with the id
  * @param id the GO ID of the render object
  * @return a pointer to the render object
  * @todo figure out if we want multiple render objects to a single game object
  */
renderObj* Renderer::getRenderObject(const unsigned int id)
{
	if (!isInit())
		return NULL;

	if (get()->m_objects.find(id) == get()->m_objects.end())
		return NULL;

	return get()->m_objects[id];
}
Example #19
0
void addFront (Node * theList, void * value) {
    if (!isInit(theList)) {
        return;
    }
    Node * newNode = initNode(value);
    newNode->next = theList->next;
    theList->next = newNode;

    return;
}
Example #20
0
/** @brief getCurrentThread
  * get a handle on the thread this is called from
  * @return the handle of the thread this is called from
  */
ThreadHandle Threadler::getCurrentThread()
{
	if (!isInit())
		return ThreadHandle();

	#ifdef WIN32
	return GetCurrentThread();
	#else
	return pthread_self();
	#endif
}
Example #21
0
/** @brief exitThread
  * force the thread this is called from to exit
  * @param exitVal this is the return value the thread should give (akin to a main's return)
  */
void Threadler::exitThread(const int & exitVal)
{
	if (!isInit())
		return;

	#ifdef WIN32
	ExitThread(exitVal);
	#else
	pthread_exit((void*)exitVal);
	#endif
}
Example #22
0
bool CameraHandler::sph2Pano()
{
  if (!isInit())
    return false;

  if (_LUT_sphere.empty())
    return false;

  return _wrapLUT_init =
      cart2Sph(_LUT_sphere, _LUT_wrap_im);
}
Example #23
0
/** @brief reg
  * register a reference to a render object
  * @param id the id of the render object to add
  * @param obj the reference to add
  * @return true on success
  */
bool Renderer::reg(const unsigned int & id, renderObj * obj)
{
	if (!isInit())
		return false;

	if (get()->m_objects.find(id) != get()->m_objects.end())
		return false;

	get()->m_objects[id] = obj;
	return true;
}
void CWordManager::GenerateXMLStringToWordEditor(_bstr_t XML_str)
{
	if (! isInit()) 
	{
		if (! InitWordLoader()) return;
	}

	
	m_WordLoader->PutstrDefaultWordTemplate(getWordTemplate());			
	m_WordLoader->LoadFromStringToWordEditor(XML_str);
}
Example #25
0
devs::Time Mealy::init(devs::Time /* time */)
{
    if (not isInit()) {
        throw utils::InternalError(
            "FSA::Mealy model, initial state not defined");
    }

    currentState(initialState());
    mPhase = IDLE;
    return 0;
}
Example #26
0
/** @brief del
  * delete a reference to a render object
  * @param id the id associated with the render object
  * @return true on success
  */
bool Renderer::del(const unsigned int & id)
{
	if (!isInit())
		return false;

	if (get()->m_objects.find(id) == get()->m_objects.end())
		return false;

	get()->m_objects.erase(id);

	return true;
}
Example #27
0
/** @brief destroyThread
  * destroy a thread
  * @param index the index of the thread to destroy
  * @return true on successful thread destruction
  */
bool Threadler::destroyThread(const ThreadID_t & index)
{
	if (!isInit())
		return false;

	#ifdef WIN32
	return TerminateThread(get()->m_threads[index],0);
	#else

	return pthread_cancel(get()->m_threads[index]);
	#endif
}
Example #28
0
/*Get the length of the list*/
int getLength (Node * theList) {
    if (!isInit(theList)) {
        return 0;
    }   
    int length = 0;
    while (theList->next != NULL) {
        length++;
        theList = theList->next;
    }

    return length;
}
BOOL CWordManager::isWordEditorActive()
{
	if (! isInit()) return FALSE;
	
	try
	{
		return m_WordLoader->GetisWordEditorActive() == VARIANT_TRUE;
	}
	catch (...)
	{
		return FALSE;
	}
}
	void Input::iProcess()
	{
		if (!isInit())
			throw Exception("not init");
		
		m_startMutex.unlock();

		// wait for the thread to be finished
		m_condMutex1.lock();
		while (!m_cond1)
			m_condVar1.wait(m_condMutex1);
		m_cond1 = false;
		m_condMutex1.unlock();
		
		// resize image data
		cv::resize(m_imgDepth, m_outDepth, m_resizing, 0, 0, CV_INTER_NN);
		cv::resize(m_imgColor, m_outColor, m_resizing, 0, 0, CV_INTER_NN);
		cv::resize(m_img3d, m_outImg3d, m_resizing, 0, 0, CV_INTER_NN);

		// compute projection matrix on first frame
		if (m_projMat.empty())
			computeProjectionMat();

		if (m_projMat.empty())
			throw Exception("projection matrix invalid");
		
		// capture data
		if (m_capturing) {
			char buffer[512];
						
			// save depth image
			sprintf_s(buffer, m_capFormat.c_str(), m_frame, "depth");
			saveCvMat(buffer, m_imgDepth);
			
			// save color image
			sprintf_s(buffer, m_capFormat.c_str(), m_frame, "color");
			saveCvMat(buffer, m_imgColor);
			
			// save 3d image
			sprintf_s(buffer, m_capFormat.c_str(), m_frame, "3d");
			saveCvMat(buffer, m_img3d);

			m_frame++;
		}
		
		// notify the thread to process the next frame
		m_condMutex2.lock();
		m_cond2 = true;
		m_condVar2.notify_all();
		m_condMutex2.unlock();
	}