Esempio n. 1
0
/** Should be called from the main message loop of the application. Can always be called,
    it will not process the message unless a scan is in progress.
 */
bool TwainIface::ProcessMessage(MSG msg)
{
    if(SourceEnabled())
    {
        TW_UINT16  twRC = TWRC_NOTDSEVENT;

        TW_EVENT twEvent;
        twEvent.pEvent = (TW_MEMREF)&msg;
        //memset(&twEvent, 0, sizeof(TW_EVENT));

        twEvent.TWMessage = MSG_NULL;

        CallTwainProc(&m_AppId, &m_Source, DG_CONTROL,
                      DAT_EVENT, MSG_PROCESSEVENT, (TW_MEMREF)&twEvent);

        if(GetRC() != TWRC_NOTDSEVENT)
        {
            TranslateMessage(twEvent);
        }

        return (twRC==TWRC_DSEVENT);

    }
    return false;
}
Esempio n. 2
0
Mat CmSaliencyRC::GetRC(CMat &img3f, double sigmaDist, double segK, int segMinSize, double segSigma)
{
	Mat imgLab3f, regIdx1i;
	cvtColor(img3f, imgLab3f, CV_BGR2Lab);
	int regNum = SegmentImage(imgLab3f, regIdx1i, segSigma, segK, segMinSize);	
	return GetRC(img3f, regIdx1i, regNum, sigmaDist);
}
Esempio n. 3
0
/** Sets the number of images which can be accpeted by the application at one time
 */
bool TwainIface::SetImageCount(TW_INT16 nCount)
{
    if(SetCapability(CAP_XFERCOUNT,(TW_UINT16)nCount,true))
    {
        m_nImageCount = nCount;
        return true;
    }
    else
    {
        if(GetRC() == TWRC_CHECKSTATUS)
        {
            TW_UINT32 count;

            if(GetCapability(CAP_XFERCOUNT, count))
            {
                nCount = (TW_INT16)count;

                if(SetCapability(CAP_XFERCOUNT, nCount))
                {
                    m_nImageCount = nCount;
                    return true;
                }
            }
        }
    }
    return false;
}
Esempio n. 4
0
/*
Sets the number of images which can be accpeted by the application at one time
*/
BOOL CTwain::SetImageCount(TW_INT16 nCount)
{
	if(SetCapability(CAP_XFERCOUNT,(TW_UINT16)nCount,TRUE))
	{
		m_nImageCount = nCount;
		return TRUE;
	}
	else
	{
		if(GetRC() == TWRC_CHECKSTATUS)
		{
		TW_UINT32 count;
			if(GetCapability(CAP_XFERCOUNT,count))
			{
				nCount = (TW_INT16)count;
				if(SetCapability(CAP_XFERCOUNT,nCount))
				{
					m_nImageCount = nCount;
					return TRUE;
				}
			}
		}
	}
	return FALSE;
}
IplImage* Saliency::Get(const IplImage* imgIn)
{
	if (imgIn != NULL)
	{
		IplImage* tt = cvCloneImage(imgIn);
		Mat sal(tt);
		Mat img3f(tt);
		img3f.convertTo(img3f, CV_32FC3, 1.0/255);//图片转换,可能是0-255之间转换到0-1之间,归一化
		sal = GetRC(img3f);
		sal.convertTo(sal,CV_32FC3,255);
		IplImage qImg(sal);

		IplImage * result = cvCreateImage(cvGetSize(imgIn),8,1);
		for (int r=0;r<imgIn->height;r++)
		{
			for (int c=0;c<imgIn->width;c++)
			{
				CvScalar col;
				col.val[0] = cvGetReal2D(&qImg,r,c);
				cvSet2D(result,r,c,col);
			}
		}
		return result;
	}
	return NULL;
}
IplImage* Saliency::Get(const string imgNameW)
{
	IplImage* tt1 = cvLoadImage(imgNameW.c_str());
	IplImage* tt2 = cvLoadImage(imgNameW.c_str());
	Mat sal(tt1);
	Mat img3f(tt2);
	//Mat sal = cvarrToMat(tt1);
	//Mat img3f = cvarrToMat(tt2);
	//Mat img3f
	//Mat sal, img3f = imread(imgNameW);
	img3f.convertTo(img3f, CV_32FC3, 1.0/255);//图片转换,可能是0-255之间转换到0-1之间,归一化
	sal = GetRC(img3f);
	
	/*string str = "D:\\rc.png";
	imwrite(str.c_str(), sal*255);
	IplImage* result = cvLoadImage("D:\\rc.png",0);*/
	IplImage* result;
	CvSize size;
	size.width = sal.cols;
	size.height = sal.rows;
	result = cvCreateImage(size,8,1);
	for(int i=0;i<result->height;i++)
	{
		for(int j=0;j<result->width;j++)
		{
			CvScalar col;
			col.val[0] = sal.at<float>(i,j)*255.0f;
			cvSet2D(result,i,j,col);
		}
	}
	return result;
}
Esempio n. 7
0
/*
Should be called from the main message loop of the application. Can always be called,
it will not process the message unless a scan is in progress.
*/
BOOL CTwain::ProcessMessage(MSG msg)
{
	if(SourceEnabled())
	{
#if 1
		TW_UINT16  twRC = TWRC_NOTDSEVENT;
		TW_EVENT twEvent;

		memset(&twEvent, 0, sizeof(TW_EVENT));
		//  twEvent.TWMessage = MSG_NULL;

		twEvent.pEvent = (TW_MEMREF)&msg;

		twRC = CallDSMEntry(&m_AppId,&m_Source,DG_CONTROL,DAT_EVENT,MSG_PROCESSEVENT,(TW_MEMREF)&twEvent);

// 		if (twRC != TWRC_DSEVENT)
// 			return FALSE;

		//  CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_EVENT,MSG_PROCESSEVENT,(TW_MEMREF)&twEvent);
		//  if(GetRC() != TWRC_NOTDSEVENT)
		//  {

		if (!_bTwainContinue)
		{
			twEvent.TWMessage = MSG_CLOSEDSREQ;
		}

		TranslateMessage(twEvent);
		//  }

		// tell the caller what happened
		return (twRC == TWRC_DSEVENT);           // returns TRUE or FALSE
//		return TRUE;
#else
	TW_EVENT twEvent;
		twEvent.pEvent = (TW_MEMREF)&msg;
		twEvent.TWMessage = MSG_NULL;
	
		CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_EVENT,MSG_PROCESSEVENT,(TW_MEMREF)&twEvent);
		if(GetRC() != TWRC_NOTDSEVENT)
		{
			TRACE("********** ProcessMessage ************\n");
			TranslateMessage(twEvent);
		}
		return FALSE;
#endif

	}
	else
	{
//		TRACE("********** ProcessMessage SourceEnabled = false ************\n");
	}
	return FALSE;
}
Esempio n. 8
0
/*
Should be called from the main message loop of the application. Can always be called,
it will not process the message unless a scan is in progress.
*/
BOOL CTwain::ProcessMessage(MSG msg)
{
	if(SourceEnabled())
	{
	TW_EVENT twEvent;
		twEvent.pEvent = (TW_MEMREF)&msg;
		twEvent.TWMessage = MSG_NULL;
	
		CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_EVENT,MSG_PROCESSEVENT,(TW_MEMREF)&twEvent);
		if(GetRC() != TWRC_NOTDSEVENT)
		{
			TranslateMessage(twEvent);
		}
		return FALSE;

	}
	return FALSE;
}
Esempio n. 9
0
Mat CmSaliencyRC::GetRC(CMat &img3f)
{
	return GetRC(img3f, 0.4, 50, 200, 0.5);
}
Mat RegionSaliency::GetRCNoColorConversion(const Mat &img3f)
{
	return GetRC(img3f, 0.4, 50, 50, 0.5);
}
Mat RegionSaliency::GetRC(const Mat &img3f)
{
	return GetRC(img3f, 0.4, 50, 50, 0.5);
}