本文介绍了如何使用TWAIN预览相机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,只获得一张图片:



1,获取点到DSM_Entry()

m_hDSMDLL = LoadLibrary(TWAIN_32.DLL);

m_lpDSMEntry =(DSMENTRYPROC)GetProcAddress(m_hDSMDLL,MAKEINTRESOURCE(1));



2,Open SourceManager

rc =(* m_lpDSMEntry)(&m_AppId,NULL,DG_CONTROL,DAT_PARENT,

MSG_OPENDSM,(TW_MEMREF)&m_hWnd);



3,选择来源

rc =(* m_lpDSMEntry)(&m_AppId,NULL,DG_CONTROL,DAT_IDENTITY,

MSG_USERSELECT, (TW_MEMREF)&m_SourceId);



4,开源

rc =(* m_lpDSMEntry)(&m_AppId,NULL,DG_CONTROL,DAT_IDENTITY,

MSG_OPENDS,(TW_MEMREF)&m_SourceId);



5,启用来源

TW_USERINTERFACE twUserInterface;

twUserInterface.ShowUI = FALSE; //

twUserInterface.ModalUI = TRUE;

twUserInterface.hParent =(TW_HANDLE)m_hWnd;

rc =(* m_lpDSMEntry)(&m_AppId, &m_SourceId,DG_CONTROL,DAT_USERINTERFACE,

MSG_ENABLEDS,(TW_MEMREF)&twUserInterface);



6,转移图片

HANDLE hBitmap = NULL;

rc =(* m_lpDSMEntry)(&m_AppId,&m_SourceId,DG_IMAGE,DAT_IMAGENATIVEXFER,

MSG_GET,(TW_MEMREF)&hBitmap); //原生模式



7,收到的图片

TW_PENDINGXFERS twPendingXfer;

rc =(* m_lpDSMEntry)( &m_AppId,&m_SourceId,DG_CONTROL,

DAT_PENDINGXFERS,MSG_ENDXFER和twPendingXfer);



8,禁用来源

rc =(* m_lpDSMEntry)(&m_AppId,&m_SourceId,DG_CONTROL,

DAT_USERINTERFACE ,MSG_DISABLEDS,(TW_MEMREF)&twUserInterface);



但是,如何通过连续的帧流或视频流预览相机?

(为了实时显示,我现在暂时用了不是办法的办法:就是在不断的循环5~8的流程,但是实时性是很差的。

不知道真正的Twain实时显示应该怎么写?)

Now,only get one image(现在只能实现单帧采图的功能):

1、Get Point To DSM_Entry()
m_hDSMDLL = LoadLibrary("TWAIN_32.DLL");
m_lpDSMEntry = (DSMENTRYPROC)GetProcAddress(m_hDSMDLL, MAKEINTRESOURCE(1));

2、Open SourceManager
rc = (*m_lpDSMEntry)(&m_AppId, NULL, DG_CONTROL, DAT_PARENT,
MSG_OPENDSM, (TW_MEMREF)&m_hWnd);

3、Select Source
rc = (*m_lpDSMEntry)(&m_AppId, NULL, DG_CONTROL, DAT_IDENTITY,
MSG_USERSELECT, (TW_MEMREF)&m_SourceId);

4、Open Source
rc = (*m_lpDSMEntry)(&m_AppId, NULL, DG_CONTROL, DAT_IDENTITY,
MSG_OPENDS, (TW_MEMREF)&m_SourceId);

5、Enable Source
TW_USERINTERFACE twUserInterface;
twUserInterface.ShowUI = FALSE; //
twUserInterface.ModalUI = TRUE;
twUserInterface.hParent = (TW_HANDLE)m_hWnd;
rc = (*m_lpDSMEntry)(&m_AppId, &m_SourceId, DG_CONTROL, DAT_USERINTERFACE,
MSG_ENABLEDS, (TW_MEMREF)&twUserInterface);

6、Transfer Image
HANDLE hBitmap = NULL;
rc = (*m_lpDSMEntry)(&m_AppId, &m_SourceId, DG_IMAGE, DAT_IMAGENATIVEXFER,
MSG_GET, (TW_MEMREF)&hBitmap); // Native Mode

7、Received Image
TW_PENDINGXFERS twPendingXfer;
rc = (*m_lpDSMEntry)(&m_AppId, &m_SourceId, DG_CONTROL,
DAT_PENDINGXFERS, MSG_ENDXFER, &twPendingXfer);

8、Disable Source
rc = (*m_lpDSMEntry)(&m_AppId, &m_SourceId, DG_CONTROL,
DAT_USERINTERFACE, MSG_DISABLEDS, (TW_MEMREF)&twUserInterface);

But,how to preview camera through a continuous flow of frames or streaming video?
(为了实时显示,我现在暂时用了不是办法的办法:就是在不断的循环5~8的流程,但是实时性是很差的。
不知道真正的Twain实时显示应该怎么写??)

推荐答案


这篇关于如何使用TWAIN预览相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 22:43