error on load Escapi.dll on BitzmaxNG (64 build)

Archives Forums/Win32 Discussion/error on load Escapi.dll on BitzmaxNG (64 build)

Fielder(Posted 2015) [#1]
On 32 stock build everything works fine, but on the 64 build the DLL can't be loaded... this is because the DLL is not 64 ?

Function SetupESCAPI ()

	esc = LoadLibraryA ("escapi.dll")


other infos about escapi and blitmax examples:

http://sol.gfxile.net/escapi/index.html

and the example was made by James Boyd (i dont't know if he is a register blitzmax forum member)


Fielder(Posted 2015) [#2]
sorry.. double post :(


Brucey(Posted 2015) [#3]
You can't load 32-bit DLLs into a 64-bit app. You will need a 64-bit version of the DLL.

You could always email the author of the DLL and see if he can build you one. (Or ask for the source, which he may give you, according to the comment at the bottom of the page, then you can build it yourself).


You'll get answers to NG related issue more quickly if you post in either Brucey's Modules or raise an issue on github.


RustyKristi(Posted 2015) [#4]
The author quoted on site and readme :


..I'd rather not give out the source code, but it is available if you have a very good reason (and some people have had such)

..Sources are available upon request. They are somewhat hackish, so I
don't feel like publishing them.



Looks like this is a very good reason, or like Brucey said request for the 64bit DLL! :D


Fielder(Posted 2015) [#5]
i've contacted the autor (Jari Komppa) requesting some new features ... and he released the new Escapi 3.. http://iki.fi/sol/zip/escapi3.zip

now i've to request a 64 bit version :)

from the autor:

// I'm kinda rewriting escapi from scratch using windows media
foundation APIs, which means that the new version will require windows
7 (possibly vista), but there'll be some nice enchancements. //

EDIT: there is the 64 Bit build :)
but something is changed... and the Escapi can't be used as the oll Escapi 2 on Blitzmaz

now i have the EXCEPTION_ACCESS_VIOLATION on:

				If OpenCaptureDevice (1, scp1) = 0
					'Print "Failed to initialise capture device! 1"

when trying to open an inexistent camera (number 2)

and opening just the 1 i have i receive a black image


Fielder(Posted 2015) [#6]
contacted "Drugged Bunny" that made the Escapi 2.1 examples for blitzmax.. maybe on next days we can have an update with Escapi 3


Fielder(Posted 2015) [#7]
Function SetupESCAPI ()

	esc = LoadLibraryA ("escapi.dll")
	
	If esc
		InitCOM					= GetProcAddress (esc, "setupESCAPI")


InitCOM is NULL... and i can't get working the escapi3 DLL... :(

this is the API description from author:

struct SimpleCapParams
{
  /* Target buffer. 
   * Must be at least mWidth * mHeight * sizeof(int) of size! 
   */
  int * mTargetBuf;
  /* Buffer width */
  int mWidth;
  /* Buffer height */
  int mHeight;
};


/* Sets up the ESCAPI DLL and the function pointers below. Call this first! */
/* Returns number of capture devices found (same as countCaptureDevices, below) */
int setupESCAPI();

/* return the number of capture devices found */
int countCaptureDevices();

/* initCapture tries to open the video capture device. 
 * Returns 0 on failure, 1 on success. 
 * Note: Capture parameter values must not change while capture device
 *       is in use (i.e. between initCapture and deinitCapture).
 *       Do *not* free the target buffer, or change its pointer!
 */
int initCapture(unsigned int deviceno, struct SimpleCapParams *aParams);

/* deinitCapture closes the video capture device. */
void deinitCapture(unsigned int deviceno);

/* doCapture requests video frame to be captured. */
void doCapture(unsigned int deviceno);

/* isCaptureDone returns 1 when the requested frame has been captured.*/
int isCaptureDone(unsigned int deviceno);

/* Get the user-friendly name of a capture device. */
void getCaptureDeviceName(unsigned int deviceno, char *namebuffer, int bufferlength);

/* Returns the ESCAPI DLL version. 0x200 for 2.0 and later (for legacy support)*/
int ESCAPIDLLVersion();

/* Returns the ESCAPI version. 0x300 for 3.0.
   When checking the version, accept higher versions too. */
int ESCAPIVersionProc();

/* 
  On properties -
  - Not all cameras support properties at all.
  - Not all properties can be set to auto.
  - Not all cameras support all properties.
  - Messing around with camera properties may lead to weird results, so YMMV.
*/

/* Gets value (0..1) of a camera property (see CAPTURE_PROPERTIES, above) */
float getCapturePropertyValueProc(unsigned int deviceno, int prop);
/* Gets whether the property is set to automatic (see CAPTURE_PROPERTIES, above) */
int getCapturePropertyAutoProc(unsigned int deviceno, int prop);
/* Set camera property to a value (0..1) and whether it should be set to auto. */
int setCapturePropertyProc(unsigned int deviceno, int prop, float value, int autoval);

/*
  All error situations in ESCAPI are considered catastrophic. If such should
  occur, the following functions can be used to check which line reported the
  error, and what the HRESULT of the error was. These may help figure out
  what the problem is.
*/

/* Return line number of error, or 0 if no catastrophic error has occurred. */
int getCaptureErrorLineProc(unsigned int deviceno);
/* Return HRESULT of the catastrophic error, or 0 if none. */
int getCaptureErrorCodeProc(unsigned int deviceno);



Brucey(Posted 2015) [#8]
I can have a look later, if you want.


Fielder(Posted 2015) [#9]
maybe Brucey , your are a Blitz-coding-monster , help from you is the best thing i can receive !

(thnak you!!!)


Brucey(Posted 2016) [#10]
I've added bah.escapi to bah mods.
It works on x86 and x64. (tested in Parallels VM on Mac with Windows 7).



... I also have a registry module under review...


Fielder(Posted 2016) [#11]
WOW THX BRUCEY!, i WILL TRY RIGHT NOW!


Fielder(Posted 2016) [#12]
It's working!, can you make a working 2 cameras example?


Brucey(Posted 2016) [#13]
You should just be able to create another instance of TEscapi and call Open(), Capture(), Close() etc with the different device number (eg. 0 for first camera, 1 for other camera).

And don't use DrawPixmap in your code... it's very slow.


Fielder(Posted 2016) [#14]
ok thank you Brucey!


xlsior(Posted 2016) [#15]
Very nice, works compiled as x86 as well as x64 for me with NG.


Fielder(Posted 2016) [#16]
2 cameras can be used without 2nd istance...
SuperStrict

Framework bah.escapi
Import brl.standardio
Import brl.pixmap
Import brl.glmax2d

Local escapi:TEscapi = New TEscapi.Create()

If Not escapi Print "Could not load escapi" ;End

Local deviceCount:Int = escapi.Count()
Print "Devices = " + deviceCount

If deviceCount = 0 Print "No devices found :-(" ;End

Local width:Int = 512
Local height:Int = 512

Local pix:TPixmap = CreatePixmap(width, height, PF_BGRA8888)

escapi.SetBuffer(pix.pixels)
escapi.SetWidth(width)
escapi.SetHeight(height)

Print "Opened device0 : " + escapi.DeviceName(0)

Graphics 1024, 512, 0

While Not KeyDown(KEY_ESCAPE)

Cls

escapi.Open(0) 
escapi.Capture(0)
Delay(500)
DrawPixmap pix, 0,0
escapi.Open(1) 
escapi.Capture(1)
Delay(500)
DrawPixmap pix,512,0

Flip

Wend

escapi.Close(0)

but sometimes it trows an exception violation....

anyone can post a minimal code to use the 2 istance?


Brucey(Posted 2016) [#17]
Your usage seems a bit strange.

Generally you would "Open" the device once, then "Capture" many times until you are finished using the device, then "Close" it.

You'd probably need to examine the source for the library to see the implications of continually opening the device - in a worst case it might leak memory or some such.

You should use "IsCaptureDone" to determine if it is finished capturing data into your pixmap buffer.
I don't know what the implications are if your capture isn't finished and you then call Open on the other device and start to capture from that one.

And don't use DrawPixmap in your production code. Really :-)


Fielder(Posted 2016) [#18]
i don't see this drawpixmap issue... i tried 4 cams with drawpixmap.. but seems ok... (i delayed everything by a delay(100) to reduce CPU usage)