Mistake in Multicam API.
Posted: 25 March 2013 04:53 PM   [ Ignore ]
New Member
Rank
Total Posts:  3
Joined  2012-12-22

Hi, I was creating python binding for CLEyeMulticam.dll and found that at this page http://codelaboratories.com/research/view/cl-eye-muticamera-api documentation for CLEyeCreateCamera function has wrong type for frameRate, it should be float instead.

CLEYEMULTICAM_API CLEyeCameraInstance CLEyeCreateCamera(GUID camUUID, CLEyeCameraColorMode mode, CLEyeCameraResolution res, int frameRate);

It will save a lot of time for other people smile.

Profile
 
 
Posted: 17 September 2014 02:14 PM   [ Ignore ]   [ # 1 ]
New Member
Rank
Total Posts:  3
Joined  2014-09-06

so ? Have you made this binding ? I would be very interested in this !!!

Profile
 
 
Posted: 17 September 2014 02:22 PM   [ Ignore ]   [ # 2 ]
New Member
Rank
Total Posts:  3
Joined  2012-12-22

Yes. Attached to this post.

File Attachments
multicam.zip  (File Size: 2KB - Downloads: 793)
Profile
 
 
Posted: 17 September 2014 03:08 PM   [ Ignore ]   [ # 3 ]
New Member
Rank
Total Posts:  3
Joined  2014-09-06

Found already smile thx for it. The only drawback is that it uses only one camera. But i ll try to make it for two. Thanks for your quick reply though. You are a life saver man. I could’t figure out all those modifications in variables that had to be made.

Profile
 
 
Posted: 18 September 2014 04:26 AM   [ Ignore ]   [ # 4 ]
New Member
Rank
Total Posts:  3
Joined  2014-09-06

I have been stragling to make it work for two cameras ... but the second window comes up BLACK. Any suggestions ?
I appreciate the time you spent on this. I have attach my code (actually its a dublicate of yours )

from ctypes import c_int, c_void_p, c_char_p, c_float, c_uint16, c_uint32, c_uint8
from ctypes import Structure, byref
import ctypes

# camera sensor parameters
CLEYE_AUTO_GAIN = 0 #[false, true]
CLEYE_GAIN = 1 #[0, 79]
CLEYE_AUTO_EXPOSURE = 2 #[false, true]
CLEYE_EXPOSURE = 3#[0, 511]
CLEYE_AUTO_WHITEBALANCE = 4 #[false, true]
CLEYE_WHITEBALANCE_RED = 5#[0, 255]
CLEYE_WHITEBALANCE_GREEN = 6#[0, 255]
CLEYE_WHITEBALANCE_BLUE = 7#[0, 255]
# camera linear transform parameters
CLEYE_HFLIP = 8#[false, true]
CLEYE_VFLIP = 9#[false, true]
CLEYE_HKEYSTONE = 10#[-500, 500]
CLEYE_VKEYSTONE = 11#[-500, 500]
CLEYE_XOFFSET = 12#[-500, 500]
CLEYE_YOFFSET = 13#[-500, 500]
CLEYE_ROTATION = 14#[-500, 500]
CLEYE_ZOOM = 15#[-500, 500]
# camera non-linear transform parameters
CLEYE_LENSCORRECTION1 = 16#[-500, 500]
CLEYE_LENSCORRECTION2 = 17#[-500, 500]
CLEYE_LENSCORRECTION3 = 18#[-500, 500]
CLEYE_LENSBRIGHTNESS = 19#[-500, 500]

#CLEyeCameraColorMode
CLEYE_MONO_PROCESSED = 0
CLEYE_COLOR_PROCESSED = 1
CLEYE_MONO_RAW = 2
CLEYE_COLOR_RAW = 3
CLEYE_BAYER_RAW = 4

#CLEyeCameraResolution
CLEYE_QVGA = 0
CLEYE_VGA = 1

class GUID(Structure):
  _fields_ = [(“Data1”, c_uint32),
        (“Data2”, c_uint16),
        (“Data3”, c_uint16),
        (“Data4”, ctypes.c_uint8 * 8)]
  def __str__(self):
      return “%X-%X-%X-%s” % (self.Data1, self.Data2, self.Data3, ‘’.join(‘X’%x for x in self.Data4))


lib = “CLEyeMulticam.dll”
dll = ctypes.cdll.LoadLibrary(lib)
dll.CLEyeGetCameraUUID.restype = GUID
dll.CLEyeCameraGetFrame.argtypes = [c_void_p, c_char_p, c_int]
dll.CLEyeCreateCamera.argtypes = [GUID, c_int, c_int, c_float]

def CLEyeGetCameraCount():
  return dll.CLEyeGetCameraCount()

def CLEyeCameraGetFrameDimensions(cam):
  width = c_int()
  height = c_int()
  dll.CLEyeCameraGetFrameDimensions(cam, byref(width), byref(height))
  return width.value, height.value
 
def CLEyeGetCameraParameter(cam, param):
  return dll.CLEyeGetCameraParameter(cam, param)
 
def CLEyeSetCameraParameter(cam, param, value):
  return dll.CLEyeSetCameraParameter(cam, param, value)
 
def CLEyeGetCameraUUID(index):
  return dll.CLEyeGetCameraUUID(index)
 
def CLEyeCreateCamera(uuid, color_mode, resolution_mode, fps):
  return dll.CLEyeCreateCamera(uuid, color_mode, resolution_mode, fps)

def CLEyeCameraStart(cam):
  return dll.CLEyeCameraStart(cam)
 
def CLEyeCameraStop(cam):
  return dll.CLEyeCameraStop(cam)
 
def CLEyeDestroyCamera(cam):
  return dll.CLEyeDestroyCamera(cam)
 
def CLEyeCameraGetFrame(cam, fram, timeout):
  return dll.CLEyeCameraGetFrame(cam, frame, 100)

if __name__ == ‘__main__’:
  import cv2.cv
  from array import array
  print ‘camera count’, CLEyeGetCameraCount()
  print ‘UUID for first camera’, CLEyeGetCameraUUID(1)
  print ‘UUID for second camera’, CLEyeGetCameraUUID(0)
 
  cam = CLEyeCreateCamera(CLEyeGetCameraUUID(1), CLEYE_COLOR_PROCESSED, CLEYE_VGA, 60.)
  cam2= CLEyeCreateCamera(CLEyeGetCameraUUID(0), CLEYE_COLOR_PROCESSED, CLEYE_VGA, 60.)
 
  print cam
  print cam2
 
  CLEyeSetCameraParameter(cam, CLEYE_AUTO_GAIN, 0)
  CLEyeSetCameraParameter(cam, CLEYE_AUTO_EXPOSURE, 0)
  CLEyeSetCameraParameter(cam, CLEYE_AUTO_WHITEBALANCE, 1)
  CLEyeSetCameraParameter(cam2, CLEYE_AUTO_GAIN, 0)
  CLEyeSetCameraParameter(cam2, CLEYE_AUTO_EXPOSURE, 0)
  CLEyeSetCameraParameter(cam2, CLEYE_AUTO_WHITEBALANCE, 1)

 
  #if set to auto just ignored
  CLEyeSetCameraParameter(cam, CLEYE_GAIN, 60)
  CLEyeSetCameraParameter(cam, CLEYE_EXPOSURE, 25)
  CLEyeSetCameraParameter(cam, CLEYE_WHITEBALANCE_RED, 50)
  CLEyeSetCameraParameter(cam, CLEYE_WHITEBALANCE_BLUE, 50)
  CLEyeSetCameraParameter(cam, CLEYE_WHITEBALANCE_GREEN, 50)

  CLEyeSetCameraParameter(cam2, CLEYE_GAIN, 60)
  CLEyeSetCameraParameter(cam2, CLEYE_EXPOSURE, 25)
  CLEyeSetCameraParameter(cam2, CLEYE_WHITEBALANCE_RED, 50)
  CLEyeSetCameraParameter(cam2, CLEYE_WHITEBALANCE_BLUE, 50)
  CLEyeSetCameraParameter(cam2, CLEYE_WHITEBALANCE_GREEN, 50)
 
  print “auto gain”, CLEyeGetCameraParameter(cam, CLEYE_AUTO_GAIN)
  print “auto exposure”, CLEyeGetCameraParameter(cam, CLEYE_AUTO_EXPOSURE)
  print “auto whitebalance”, CLEyeGetCameraParameter(cam, CLEYE_AUTO_WHITEBALANCE)
  print “gain”, CLEyeGetCameraParameter(cam, CLEYE_GAIN)
  print “exposure”, CLEyeGetCameraParameter(cam, CLEYE_EXPOSURE)
  print “red”, CLEyeGetCameraParameter(cam, CLEYE_WHITEBALANCE_RED)
  print “green”, CLEyeGetCameraParameter(cam, CLEYE_WHITEBALANCE_BLUE)
  print “blue”, CLEyeGetCameraParameter(cam, CLEYE_WHITEBALANCE_GREEN)
 
 
  x, y = CLEyeCameraGetFrameDimensions(cam)
  x2, y2 = CLEyeCameraGetFrameDimensions(cam2)
  print x, y,x2,y2
  CLEyeCameraStart(cam)
  CLEyeCameraStart(cam2)
 
  frame = ctypes.create_string_buffer(x * y * 4)
  frame2 = ctypes.create_string_buffer(x2 * y2 * 4)
 
  cv2.cv.NamedWindow( “camera”, 1 )
  cv2.cv.NamedWindow( “camera2”, 1 )
 
  imagen=cv2.cv.CreateImage((x, y), 8, 4)
  imagen2=cv2.cv.CreateImage((x2, y2), 8, 4)

  #mat = cv2.cv.CreateMat(x, y, 0)
  #mat2 = cv2.cv.CreateMat(x2, y2, 0)
 

  i = 0
  while True:
      i += 1
      CLEyeCameraGetFrame(cam, frame, 100)
      cv2.cv.SetData(imagen, array(‘B’, frame[:]).tostring())
      cv2.cv.ShowImage( “camera”, imagen )
      CLEyeCameraGetFrame(cam2, frame2, 100)
      cv2.cv.SetData(imagen2, array(‘B’, frame2[:]).tostring())
     
     
      cv2.cv.ShowImage( “camera2”, imagen2 )
     
      #cv2.cv.SaveImage(“r:\\Cap\\%i.jpg” % i, imagen)
      if cv2.waitKey(1) & 0xFF == ord(‘q’):
          break

       
  CLEyeCameraStop(cam)         
  CLEyeDestroyCamera(cam)
  CLEyeCameraStop(cam2)         
  CLEyeDestroyCamera(cam2)
  cv2.destroyAllWindows()

Profile
 
 
 
 


RSS 2.0     Atom Feed