Hello Gael (sorry, I just don't get the dots...),
Am Freitag, den 27.10.2006, 08:46 +0200 schrieb Gael Varoquaux:
> Worked great for me ! My approach was to write a small wrapper C
> (actually C++, with "extern C" linking) library that exposed only what I
> needed of the camera interface, in a "python-friendly" way, and to wrap
> it with ctypes. I controlled a "Pixis" princeton instruments camera this
> way. As I said, it worked surprisingly well. I can send the code as an
> example if you wish.
Yes, that would be really nice! I think, I am doing the same thing. In
the attachment, you find my dll-code, which I am still working on --so
it is not ready to use!--, if you have any comments I will be happy.
Lars
--
Dipl.-Ing. Lars Friedrich
Optical Measurement Technology
Department of Microsystems Engineering -- IMTEK
University of Freiburg
Georges-Köhler-Allee 102
D-79110 Freiburg
Germany
phone: +49-761-203-7531
fax: +49-761-203-7537
room: 01 088
email: [EMAIL PROTECTED]
//***** pvcamDLL.cpp *****
// This file is the main file to generate pvcamDLL.dll.
// pvcamDLL.dll is a shared library that can be used to communicate with a camera
// that has a PVCAM-interface, for example the "coolsnap ES" camera by Photometrics.
// Only a very basic set of functions is implemented.
// This library is intended to be used by the python class PVCAMCamera,
// but can be called from any other software.
// started: July 2006
// author: Lars Friedrich
// last change: 2006-08-30
#include "stdafx.h"
#include "stdio.h"
// include PVCAM-files:
#include "master.h"
#include "pvcam.h"
static char cam_name[CAM_NAME_LEN]; /* camera name */
static int16 hCam; /* camera handle */
static int16 *buffer;
static uns32 size; /* size of one frame in bytes */
// The buffer has to be big enough to hold 50 frames. This hardcoded value is believed to be
// a good compromise between memory needed by big frames
// (1M pixel/frame * 2 byte/pixel * 50 frames = 100 Mbyte) and the minimal time available
// to read the buffer with small ROIs (e. g. at 100 Hz: 10 ms/frame * 49 frames = 490 ms).
const int bufSize = 50; /* size of the buffer in frames */
// The following function was autogenerated by using a "simple-dll-project" in VisualC++.
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
return TRUE;
}
int test(uns16 *data)
{
printf("%u", *data);
return 0;
}
// The following function initializes and opens the first (index = 0) PVCAM-camera connected
// to the system. Other variables s are initialized with NULL or 0.
// This function has to be called and return 0 before any other function can be used.
int initCam()
{
buffer = NULL;
size = 0;
pl_pvcam_init();
pl_cam_get_name(0, cam_name);
if(!pl_cam_open(cam_name, &hCam, OPEN_EXCLUSIVE))
return -1;
return 0;
}
// The following function closes and uninitializes the camera referenced by hcam. It has to be called
// before the camera is used by a different program to free resources.
int closeCam()
{
if(!pl_cam_close(hCam))
return -1;
if(!pl_pvcam_uninit())
return -1;
return 0;
}
// The following function writes the serial and parallel chipsize in pixel to pyData.
// This data will be needed by the calling program to chose a region of interest (ROI).
int getChipSize(uns16 *pyData)
{
pl_get_param(hCam, PARAM_SER_SIZE, ATTR_CURRENT, pyData);
pl_get_param(hCam, PARAM_PAR_SIZE, ATTR_CURRENT, pyData + 1);
return 0;
}
// The following function starts the continuous acquisition mode of the camera.
// The argument pyOptions specifies the ROI in pixels and the exposure time in ms.
// The argument pyBuffer is the buffer where image data is written to. The calling program is
// responsibleof appropriate memory allocation and freeing of memory after the acquisition
// is stopped.
// The buffer is written to in circulare mode with overwrite.
int startContMode(int16 *pyOptions, int16* pyBuffer)
{
buffer = pyBuffer;
if(!pl_exp_init_seq()) // initialize sequence
return -1;
rgn_type region = {pyOptions[0], pyOptions[1], 1,
pyOptions[2], pyOptions[3], 1};
if(!pl_exp_setup_cont(hCam, 1, ®ion, TIMED_MODE, pyOptions[4], &size, CIRC_OVERWRITE))
return -1;
if(!pl_exp_start_cont(hCam, buffer, bufSize * size))
return -1;
return 0;
}
// The following function stops the acquisition.
int stopContMode()
{
if(!pl_exp_stop_cont(hCam, CCS_NO_CHANGE))
return -1;
return 0;
}
// The following function returns the index of the frame in the buffer that was acquired last.
int getLatestFrame()
{
void **framePtr = new void*;
if (!pl_exp_get_latest_frame(hCam, framePtr))
return -1;
// Now, framePtr holds a pointer to a pointer to the data.
// The offset to the last frame in pixels:
int offset = (int16*) *framePtr - buffer;
// The framePtr is not needed anymore.
delete framePtr;
// The offset in "number of frames" (ranging from 0 to 9) can be found by
// normalizing to the size of one frame in pixel (2 byte / pixel)
offset /= (size / 2);
return offset;
}
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion