Пример #1
0
// starts video acquisition (public function)
int SwV4LDevice::VDInitAll()
{
    if(StartGrab())
    	return -1;
    
	return 0;
}
Пример #2
0
void static OnLButtonDown (HWND hWnd, 
                           POINTS ptsMouse)
   {
   PILINE         pILine ;
   POINT          ptMouse ;

   pILine = ILData (hWnd) ;

   pILine->ptsMouse = ptsMouse ;
   ptMouse.x = ptsMouse.x ;
   ptMouse.y = ptsMouse.y ;

#if 0
   // Russ said this is bad, so don't do it
   if (PtInRect (&pILine->rectLeftBk, ptMouse))
      ILPageLeftRight (hWnd, pILine, TRUE) ;

   else if (PtInRect (&pILine->rectRightBk, ptMouse))
      ILPageLeftRight (hWnd, pILine, FALSE) ;

   else if (PtInRect (&pILine->rectLeftGrab, ptMouse))
#endif
   if (PtInRect (&pILine->rectLeftGrab, ptMouse) ||
       PtInRect (&pILine->rectLeftBk, ptMouse))
      {
      ILMode (pILine) = ILModeLeft ;
      StartGrab (hWnd, pILine) ;
      }

   else if (PtInRect (&pILine->rectRightGrab, ptMouse) ||
            PtInRect (&pILine->rectRightBk, ptMouse))
      {
      ILMode (pILine) = ILModeRight ;
      StartGrab (hWnd, pILine) ;
      }

   else if (PtInRect (&pILine->rectCenterGrab, ptMouse))
      {
      ILMode (pILine) = ILModeCenter ;
      StartGrab (hWnd, pILine) ;
      }
   }
Пример #3
0
bool CAnimatedGrabHandler::SetGrab(SmartScriptTable &rParams)
{
	// NOTE Aug 16, 2007: <pvl> if there's another grab action under way, this one fails
	// first the cheaper check (should also cover the case when output is not yet set because of longer transition time)
	if (m_grabStats.IKActive == true)
		return false;
	// then the more expensive check
	if (IAnimationGraphState* pAGState = m_pActor->GetAnimationGraphState())
	{
		const char* grabActive = pAGState->QueryOutput("GrabActive");
		if (grabActive != NULL && grabActive[0] != 0)
			return false;
	}
	if (m_grabStats.grabId > 0)
		Reset();

	m_grabStats.useIKRotation = false;
	rParams->GetValue("useIKRotation",m_grabStats.useIKRotation);

	m_grabStats.limbNum = 0;

	SmartScriptTable limbsTable;
	if (rParams->GetValue("limbs",limbsTable))
	{
		IScriptTable::Iterator iter = limbsTable->BeginIteration();
	
		while(limbsTable->MoveNext(iter))
		{
			const char *pLimb;
			iter.value.CopyTo(pLimb);

			int limbIdx = m_pActor->GetIKLimbIndex(pLimb);
			if (limbIdx > -1 && m_grabStats.limbNum<GRAB_MAXLIMBS)
				m_grabStats.limbId[m_grabStats.limbNum++] = limbIdx;
		}

		limbsTable->EndIteration(iter);
	}

	m_grabStats.usingAnimation = false;

	const char * pCarryAnimGraphInput = 0;
	if (rParams->GetValue("carryAnimGraphInput",pCarryAnimGraphInput))
	{
		const int maxNameLen = SGrabStats::s_maxAGInputNameLen;
		strncpy(m_grabStats.carryAnimGraphInput,pCarryAnimGraphInput,maxNameLen);
		m_grabStats.carryAnimGraphInput[maxNameLen-1] = 0;
	}
	
	SmartScriptTable animationTable;
	if (rParams->GetValue("animation",animationTable))
	{
		const char *pAnimGraphSignal = NULL;

		if (animationTable->GetValue("animGraphSignal",pAnimGraphSignal))
		{
			const int maxNameLen = SGrabStats::s_maxAGInputNameLen;
			strncpy(m_grabStats.grabAnimGraphSignal,pAnimGraphSignal,maxNameLen);
			m_grabStats.grabAnimGraphSignal[maxNameLen-1] = 0;
		}

		// TODO Dez 15, 2006: <pvl> if there's no graph signal, consider
		// returning false - won't work without graph signal anyway
		if (pAnimGraphSignal)
		{
			m_grabStats.usingAnimation = true;
			m_grabStats.usingAnimationForDrop = true;
			m_grabStats.usingAnimationForGrab = true;
		}

		if (animationTable->GetValue("forceThrow",m_grabStats.throwDelay))
		{
			//m_grabStats.grabDelay = 0.0f;
			m_grabStats.maxDelay = m_grabStats.throwDelay;
		}

		m_grabStats.grabbedObjOfs.zero();
		animationTable->GetValue("grabbedObjOfs",m_grabStats.grabbedObjOfs);

		m_grabStats.releaseIKTime = 0.0f;
		animationTable->GetValue("releaseIKTime",m_grabStats.releaseIKTime);
	} else {
		if (rParams->GetValue("grabAnim",animationTable))
		{
			m_grabStats.usingAnimationForGrab = true;

			m_grabStats.releaseIKTime = 0.0f;
			animationTable->GetValue("releaseIKTime",m_grabStats.releaseIKTime);

			m_grabStats.grabbedObjOfs.zero();
			animationTable->GetValue("grabbedObjOfs",m_grabStats.grabbedObjOfs);

			const char *pAnimGraphSignal = NULL;
			if (animationTable->GetValue("animGraphSignal",pAnimGraphSignal))
			{
				const int maxNameLen = SGrabStats::s_maxAGInputNameLen;
				strncpy(m_grabStats.grabAnimGraphSignal,pAnimGraphSignal,maxNameLen);
				m_grabStats.grabAnimGraphSignal[maxNameLen-1] = 0;
			}
		}
		if (rParams->GetValue("dropAnim",animationTable))
		{
			m_grabStats.usingAnimationForDrop = true;

			// NOTE Feb 10, 2007: <pvl> this is just to get around the
			// condition in CBaseGrabHandler::SetDrop().  If we don't set
			// throwDelay to something bigger than zero SetDrop() executes
			// StartDrop() immediately.
			// All of this stuff around maxDelay, throwDelay etc. should be
			// rewritten but in a way that doesn't break existing behaviour.
			m_grabStats.throwDelay = 1000.0f;

			const char *pAnimGraphSignal = NULL;
			if (animationTable->GetValue("animGraphSignal",pAnimGraphSignal))
			{
				const int maxNameLen = SGrabStats::s_maxAGInputNameLen;
				strncpy(m_grabStats.dropAnimGraphSignal,pAnimGraphSignal,SGrabStats::s_maxAGInputNameLen);
				m_grabStats.dropAnimGraphSignal[maxNameLen-1] = 0;
			}
		}
		m_grabStats.usingAnimation = m_grabStats.usingAnimationForDrop || m_grabStats.usingAnimationForGrab;
	}

	m_grabStats.followBoneID = -1;

	const char *followBone;
	if (rParams->GetValue("followBone",followBone))
	{
		ICharacterInstance *pCharacter = m_pActor->GetEntity()->GetCharacter(0);
		if (pCharacter)
			m_grabStats.followBoneID = pCharacter->GetISkeletonPose()->GetJointIDByName(followBone);
	}
	// TODO Dez 15, 2006: <pvl> consider returning false if bone ID is -1
	// at this point - it won't work anyway without bone ID
	

	//FIXME:remove this garbage when the grabbing setup is refactored too
	float savedThrowDelay(m_grabStats.throwDelay);
	if ( ! CBaseGrabHandler::SetGrab(rParams))
		return false;

	m_grabStats.additionalRotation.SetIdentity();
	m_grabStats.origRotation.SetIdentity();

	if (m_grabStats.carryAnimGraphInput[0])
	{
		m_pActor->SetAnimationInput("CarryItem",m_grabStats.carryAnimGraphInput);	
	}
	if (m_grabStats.grabAnimGraphSignal[0])
	{
		m_pActor->SetAnimationInput("Signal",m_grabStats.grabAnimGraphSignal);
	}
	if ( ! m_grabStats.usingAnimationForGrab)
	{
		StartGrab();
	}

	m_grabStats.maxDelay = m_grabStats.throwDelay = savedThrowDelay;

	return true;
}
Пример #4
0
// ref effetv video.c function video_init()
int SwV4LDevice::VDopen(char * device, tBoxSize *newSize)
{
	int maxc;
	fprintf(stderr, "[V4L]::VDopen device '%s'\n", device);
	
	if(device == NULL){
    	videodevice = new char [ strlen(DEFAULT_VIDEO_DEVICE) +1];
		strcpy(videodevice, DEFAULT_VIDEO_DEVICE);
	}
	else {
		videodevice = new char [ strlen(device) +1];
		strcpy(videodevice, device);
	}

    if(v4l_open(videodevice)) {
		
		return -1;
	}
    v4l_setdefaultnorm(norm); // moved after getcapabilities to get the channel number
    v4l_getcapability();
//    v4lsetdefaultnorm(norm);
	// Read channel ...
	
	
    
    if(!(vd.capability.type & VID_TYPE_CAPTURE)) {
    	fprintf(stderr, "[V4L]::VDOpen: This device seems not to support video capturing.\n");
    	return -1;
	}
	hastuner = 0;
	if((vd.capability.type & VID_TYPE_TUNER)) {
		hastuner = 1;
		frequency_table = 0; // CSE : didn't undestand ...  = freq;
		TVchannel = 0;
	}

	// set acquisition size
	changeSize(newSize);

    getcurrentchannel();
	
	maxc = vd.capability.channels;
	if((maxc) && (channel <= maxc)) {
    	if(setchannel(channel))
			 return -1;
	}
	if(channel >= maxc) {
		channel = maxc;
		if(setchannel(channel))
			 return -1;
	}
	
    if(v4l_mmap()) {
    	fprintf(stderr, "[V4L]::VDopen: mmap interface is not supported by this driver.\n");
        return -1;
	}

 	/* quick hack for v4l driver that does not support double buffer capturing */
	if(vd.mbuf.frames < 2) {
    	fprintf(stderr, "[V4L]::VDopen: double buffer capturing with mmap is not supported.\n");
        return -1;
	}
    /* OLD COMMENT detecting a pixel format supported by the v4l driver.
     * video_set_grabformat() overwrites both 'converter' and 'converter_hflip'.
     * If 'converter' is non-NULL, palette converter must be initialized. */
	if(setGrabFormat(palette)) {
		fprintf(stderr, "[V4L]::VDopen: ERROR : Can't find a supported pixel format.\n");
        return -1;
	}

    v4l_getpicture();
    picture_brightness = vd.picture.brightness;
    picture_hue = vd.picture.hue;
	picture_colour = vd.picture.colour;

/*** END COPY ****/

	if(StartGrab()) {
		fprintf(stderr, "[V4L]::VDopen: Can't start grab.\n");
  		//normal at beginning or when capture has been stopped
	}

	initialised = true;
//    echo();

	return 0;
}
Пример #5
0
int SwV4LDevice::changeSize(tBoxSize * newSize) 
{
	int w=0, h=0;
	if(newSize->width == 0 || newSize->height == 0) {
        w = DEFAULT_VIDEO_WIDTH;
        h = DEFAULT_VIDEO_HEIGHT;
    }
    else {
    	w = newSize->width;
     	h = newSize->height;
    }

	if(w > MAXWIDTH || h > MAXHEIGHT) {
        w = MAXWIDTH;
        h = MAXHEIGHT;
        fprintf(stderr, "capturing size is set to %dx%d.\n", w, h);
	} else if(w < MINWIDTH || h < MINHEIGHT) {
        w = MINWIDTH;
        h = MINHEIGHT;
        fprintf(stderr, "capturing size is set to %dx%d.\n", w, h);
	}
	
	video_width = w;
	video_height = h;
	video_area = video_width * video_height;
    // tell caller that the size changed
	newSize->width  = w;
	newSize->height = h;

	unsigned char first = 1;
	if(framebuffer) {
		first = 0;
		if (StopGrab() < 0) {
			 fprintf(stderr, "[V4L]::StopGrab failed\n");
			 return -1;
		}
		if(v4l_munmap()<0) {
			fprintf(stderr, "[V4L]::v4l_munmap failed\n");
			return -1;
		}
		vd.frame = 0;
		delete [] framebuffer;
	}
	
	framebuffer = (RGB32 *)malloc(video_area*sizeof(RGB32));
    if(framebuffer == NULL) {
    	fprintf(stderr, "[V4L]: Memory allocation error.\n");
        return -1;
	}
	
	if(first) {
		if(v4l_grabinit(video_width, video_height)) {
			fprintf(stderr, "[V4L]::v4l_grabinit failed\n");
			return -1;
		}
	}
	else {
		// set size
		if(v4l_grabinit(video_width, video_height)) {
			fprintf(stderr, "[V4L]::v4l_grabinit failed\n");
			return -1;
		}
		
		if(v4l_mmap()<0) {
			fprintf(stderr, "[V4L]::v4l_mmap() failed\n");
			return -1;
		}
		if(StartGrab()<0) {
			fprintf(stderr, "[V4L]::StartGrab() failed\n");
			return -1;
		}
		
	}
	return 0;
}