Open lens on camera

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
thlibby
Posts: 2
Joined: Fri Jul 02, 2010 4:52 pm

Open lens on camera

Post by thlibby » Fri Jul 02, 2010 6:01 pm

I am evaluating GdTwain Pro ActiveX with Visual FoxPro. Camera is a PowerShot SX100 IS. When I plug the camera into the USB port the lens retracts and I cannot figure out how to open the lens to take a picture using GdTwain. Is there a way to tell the camera to open the lens. Below is the code I am using and the log file generated from TwainLogStart().

Thanks
Tom

Code:

Code: Select all

THISFORM.gdTwain.TwainLogStart("c:\tlog.txt")
lcSource = THISFORM.gdTwain.TwainSelectSource(THISFORM.HWnd)

THISFORM.gdTwain.TwainOpenSource(lcSource)
*THISFORM.gdTwain.TwainOpenDefaultSource()
THISFORM.gdTwain.TwainSetCurrentPixelType(2)  &&Color
nImageID = THISFORM.gdTwain.TwainAcquireToDib(THISFORM.HWnd)
IF nImageID <> 0
	THISFORM.gdViewer.DisplayFromGdiDib(nImageID) 
	&& TwainAcquireToGdPictureImage
	THISFORM.gdTwain.SaveAsJpeg("c:\image.jpg")
	THISFORM.gdTwain.TwainCloseSource()
ENDIF 
THISFORM.gdTwain.TwainLogStop()

Code: Select all

#GdTwain Log Start. Version: 644

RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 3
-------------------
Start: OpenSource.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 3
-------------------
GDTWAIN_Mgr: Start Getting DAT_STATUS
RC:   TWRC_ENDOFLIST
CC:   TWCC_SUCCESS
State: 3
-------------------
GDTWAIN_Mgr: End Getting DAT_STATUS
RC:   TWRC_ENDOFLIST
CC:   TWCC_SUCCESS
State: 3
-------------------
End: OpenSource.
RC:   TWRC_ENDOFLIST
CC:   TWCC_SUCCESS
State: 3
-------------------
SetCapOneValue: Please, open source First!.
RC:   TWRC_FAILURE
CC:   TWCC_OPERATIONERROR
State: 3
-------------------
Start: AcquireNative.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 3
Source: WIA-Canon PowerShot SX100 IS
Manufacturer: Generic
-------------------
End: AcquireNative.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 3
-------------------
#GdTwain Log Stop.

User avatar
Loïc
Site Admin
Posts: 5696
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Open lens on camera

Post by Loïc » Sun Jul 04, 2010 6:46 pm

Hi Tom,

You do not open the selected device correctly:

This line is wrong:

Code: Select all

lcSource = THISFORM.gdTwain.TwainSelectSource(THISFORM.HWnd)
First the TwainSelectSource method doesn't return a String but a Boolean !

You should use the following line instead:

Code: Select all

THISFORM.gdTwain.TwainOpenDefaultSource()
If the problem persists, please report the new generated log with this line.

Kind regards,

Loïc

thlibby
Posts: 2
Joined: Fri Jul 02, 2010 4:52 pm

Re: Open lens on camera

Post by thlibby » Tue Jul 06, 2010 4:08 pm

I tried the below code with a Logitech QuickCam Pro 9000 and it worked. However, I need to get this to work with the PowerShot SX100 IS. The lens closes when I plug in the USB cable and I am not able to open the lens.

Code: Select all

THISFORM.gdTwain.TwainLogStart("c:\tlog.txt")
THISFORM.gdTwain.TwainOpenDefaultSource()
THISFORM.gdTwain.TwainSetCurrentPixelType(2)  &&Color
nImageID = THISFORM.gdTwain.TwainAcquireToGdPictureImage(THISFORM.HWnd)

IF nImageID <> 0
	THISFORM.gdTwain.SaveAsJpeg("c:\image.jpg")
	THISFORM.gdTwain.TwainCloseSource()
	THISFORM.gdViewer.DisplayFromFile("c:\image.jpg")
ENDIF 
THISFORM.gdTwain.TwainLogStop()

Code: Select all

#GdTwain Log Start. Version: 644

RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_SUCCESS // TWmsg: fc
-------------------
Start: AcquireNative.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
Source: WIA-Canon PowerShot SX100 IS
Manufacturer: Generic
-------------------
AcquireNative: Retrieving current device configuration - Start.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_GETCURRENT ->RC: TWRC_FAILURE CC: TWCC_BADCAP // TWmsg: 0
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_GETCURRENT ->RC: TWRC_FAILURE CC: TWCC_BADCAP // TWmsg: 0
-------------------
AcquireNative: Retrieving current device configuration - End.
RC:   TWRC_FAILURE
CC:   TWCC_BADCAP
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_GETCURRENT ->RC: TWRC_SUCCESS // TWmsg: fc
-------------------
Start: WaitForXfer.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_GETCURRENT ->RC: TWRC_SUCCESS // TWmsg: fc
-------------------
Start: SetXferMech.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_SUCCESS // TWmsg: fc
-------------------
End: SetXferMech.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
Start: EnableSource.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_USERINTERFACE - MSG: MSG_ENABLEDS ->RC: TWRC_FAILURE CC: TWCC_OPERATIONERROR // TWmsg: 510
-------------------
DS - DG_CONTROL/DAT_USERINTERFACE: Fail to enable Source.
RC:   TWRC_FAILURE
CC:   TWCC_OPERATIONERROR
State: 4
-------------------
End: EnableSource.
RC:   TWRC_FAILURE
CC:   TWCC_OPERATIONERROR
State: 4
-------------------
End: WaitForXfer.
RC:   TWRC_FAILURE
CC:   TWCC_OPERATIONERROR
State: 4
-------------------
AcquireNative: Transfer failed or cancelled.
RC:   TWRC_FAILURE
CC:   TWCC_OPERATIONERROR
State: 4
-------------------
End: AcquireNative.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
#GdTwain Log Stop.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest