Vizible’s Blog

C# – Control logitech orbit cemera

Posted in Programming by wearetherock on August 4, 2009

Try RoboRealm but too complicate , So I move to  http://comrade.ownz.com/projects/logimove.html it  not suported Zoomming, but ok.

~
Coding in C#

=====================================

using System;
using System.Runtime.InteropServices;

public class Test
{
    [DllImport("logimove.dll")]
    static extern void ReloadDevices();
    //Reloads the list of system devices to operate on.

    [DllImport("logimove.dll")]
    static extern int GetDeviceCount();
    //Retrieves the number of system devices to operate on.

    [DllImport("logimove.dll")]
    static extern  IntPtr GetDevicePath(int iDeviceIndex);
    //Retrieves the path of a device. iDeviceIndex is in range of 0 to GetDeviceCount()-1.

    [DllImport("logimove.dll")]
    static extern int OpenDevice( IntPtr DevicePath);
    //Opens the device with specified path, and returns a handle to it.
    //If failed, returns 0.
    //Note: HANDLE is a 32-bit integer.

    [DllImport("logimove.dll")]
    static extern int CloseDevice(int hDevice);
    //Closes an opened device, by its handle. Returns whether operation succeeded or not.

    [DllImport("logimove.dll")]
    static extern void MoveLeft(int hDevice);
    //Pans camera, specified by device handle, to the left.

    [DllImport("logimove.dll")]
    static extern void MoveRight(int hDevice);
    //Pans camera, specified by device handle, to the right.

    [DllImport("logimove.dll")]
    static extern void MoveTop(int hDevice);
    //Tilts camera, specified by device handle, up.

    [DllImport("logimove.dll")]
    static extern void MoveBottom(int hDevice);
    //Tilts camera, specified by device handle, down.

    [DllImport("logimove.dll")]
    static extern void MoveHome(int hDevice);
    //Moves the camera to its home position.

    [DllImport("logimove.dll")]
    static extern void Move(int hDevice, int iPosition);
    //* MOVE_HOME = 0x00000000
    //* MOVE_LEFT = 0x0000FF80
    //* MOVE_RIGHT = 0x00000080
    //* MOVE_TOP = 0xFF800000
    //* MOVE_BOTTOM = 0x00800000

    public static void Main(String[] args)
    {
        int count = GetDeviceCount();
        Console.WriteLine(count);

        //my logitech cemera at index 1
        IntPtr path = GetDevicePath(1);
        int device = OpenDevice(path);

        for (int i = 0; i < 100; i++)
        {
            System.Threading.Thread.Sleep(10);
            // move right
            Move(device, 0x00000080);
        }
    }
}
Advertisements
Tagged with: , ,

2 Responses

Subscribe to comments with RSS.

  1. wearetherock said, on August 4, 2009 at 12:32 pm

    if you see library document @ http://comrade.ownz.com/projects/logimove.html
    I changed HANDLE to int, changed const char* to IntPtr, just try it but ok.

  2. wearetherock said, on August 4, 2009 at 12:35 pm

    I also tried this library from Python with ctypes.

    from ctypes import *
    import time
    
    logimove = windll.LoadLibrary("logimove.dll")
    count = logimove.GetDeviceCount()
    print count
    
    path = logimove.GetDevicePath(c_int(1))
    cpath = c_char_p(path)
    
    device = logimove.OpenDevice(cpath)
    cdevice = c_int(device)
    print 'device :', cdevice
    
    
    for i in range (0,100) :
    	print logimove.MoveRight(cdevice)
    	time.sleep(0.05)
    	
    print logimove.MoveHome(cdevice)
    

    It work well 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: