NP enumerations in c#

Post Reply
leith
Posts: 194
Joined: Tue Jan 02, 2007 2:17 pm

NP enumerations in c#

Post by leith »

btw, I've noticed that the enumerations referenced in the documentation are not making their way through COM and through the .net COM interop as far as I can tell... unless you folks can point me to where they import to. I've imported lots of COM libraries through COM interop before, and they usually do show up as enumerations. In the meantime, I've just been looking at the c++ header files you folks provide in the include directory of the SDK, to get the actual integer values. Passing them works fine for now.
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: NP enumerations in c#

Post by beckdo »

Hey Brad,

You'll have to manually #define the values you need for SetOption in your managed code. We don't have any managed #defines you can include currently. If there is anything else that you're not able to get access to, let us know.
hpcv
Posts: 58
Joined: Tue Oct 23, 2007 2:09 pm

Re: NP enumerations in c#

Post by hpcv »

I have ported the most used enums and constants to C# from the OptiTrack headers. Haven't made everything into nice names, but a bit of manual work or a clever regex should do the trick. Hope this is useful to you (or someone)!

Code: Select all

    enum NPHWModel
    {
        Oldtrackir = 0x100800a8,
        Smartnav = Oldtrackir + 1,
        Trackir = Smartnav + 1,
        Optitrack = Trackir + 1,
        Unknown = Optitrack + 1
    }

    enum NPHWRevision
    {
        OldtrackirLegacy = 0x200800b8,
        OldtrackirBasic = OldtrackirLegacy + 1,
        OldtrackirEg = OldtrackirBasic + 1,
        OldtrackirAt = OldtrackirEg + 1,
        OldtrackirGx = OldtrackirAt + 1,
        OldtrackirMac = OldtrackirGx + 1,
        SmartnavBasic = OldtrackirMac + 1,
        SmartnavEg = SmartnavBasic + 1,
        SmartnavAt = SmartnavEg + 1,
        SmartnavMacBasic = SmartnavAt + 1,
        SmartnavMacAt = SmartnavMacBasic + 1,
        TrackirBasic = SmartnavMacAt + 1,
        TrackirPro = TrackirBasic + 1,
        OptitrackBasic = TrackirPro + 1,
        OptitrackFlex = OptitrackBasic + 1,
        Unknown = OptitrackFlex + 1
    }

    enum NPLed
    {
        One = 0,
        Two = One + 1,
        Three = Two + 1,
        Four = Three + 1
    }

    enum NPOption // TODO: fix casing on all items
    {
        StatusGreenOnTracking = 0,
        TrackedObjectColor = StatusGreenOnTracking + 1,
        UntrackedObjectsColor = TrackedObjectColor + 1,
        ObjectColorOption = UntrackedObjectsColor + 1,
        DrawScale = ObjectColorOption + 1,
        Threshold = DrawScale + 1,
        ObjectMassWeight = Threshold + 1,
        ObjectRatioWeight = ObjectMassWeight + 1,
        ProximityWeight = ObjectRatioWeight + 1,
        StaticCountWeight = ProximityWeight + 1,
        ScreenCenterWeight = StaticCountWeight + 1,
        LastObjectTrackedWeight = ScreenCenterWeight + 1,
        ObjectMassMin = LastObjectTrackedWeight + 1,
        ObjectMassMax = ObjectMassMin + 1,
        ObjectMassIdeal = ObjectMassMax + 1,
        ObjectMassOutOfRange = ObjectMassIdeal + 1,
        OBJECT_RATIO_MIN = ObjectMassOutOfRange + 1,
        OBJECT_RATIO_MAX = OBJECT_RATIO_MIN + 1,
        OBJECT_RATIO_IDEAL = OBJECT_RATIO_MAX + 1,
        OBJECT_RATIO_OUT_OF_RANGE = OBJECT_RATIO_IDEAL + 1,
        PROXIMITY_MIN = OBJECT_RATIO_OUT_OF_RANGE + 1,
        PROXIMITY_MAX = PROXIMITY_MIN + 1,
        PROXIMITY_IDEAL = PROXIMITY_MAX + 1,
        PROXIMITY_OUT_OF_RANGE = PROXIMITY_IDEAL + 1,
        STATIC_COUNT_MIN = PROXIMITY_OUT_OF_RANGE + 1,
        STATIC_COUNT_MAX = STATIC_COUNT_MIN + 1,
        STATIC_COUNT_IDEAL = STATIC_COUNT_MAX + 1,
        STATIC_COUNT_OUT_OF_RANGE = STATIC_COUNT_IDEAL + 1,
        SCREEN_CENTER_MIN = STATIC_COUNT_OUT_OF_RANGE + 1,
        SCREEN_CENTER_MAX = SCREEN_CENTER_MIN + 1,
        SCREEN_CENTER_IDEAL = SCREEN_CENTER_MAX + 1,
        SCREEN_CENTER_OUT_OF_RANGE = SCREEN_CENTER_IDEAL + 1,
        LAST_OBJECT_MIN = SCREEN_CENTER_OUT_OF_RANGE + 1,
        LAST_OBJECT_MAX = LAST_OBJECT_MIN + 1,
        LAST_OBJECT_IDEAL = LAST_OBJECT_MAX + 1,
        LAST_OBJECT_OUT_OF_RANGE = LAST_OBJECT_IDEAL + 1,
        STATUS_LED_ON_START = LAST_OBJECT_OUT_OF_RANGE + 1,
        ILLUMINATION_LEDS_ON_START = STATUS_LED_ON_START + 1,
        CAMERA_ROTATION = ILLUMINATION_LEDS_ON_START + 1,
        MIRROR_X = CAMERA_ROTATION + 1,
        MIRROR_Y = MIRROR_X + 1,
        SEND_EMPTY_FRAMES = MIRROR_Y + 1,
        CameraId = SEND_EMPTY_FRAMES + 1,
        CAMERA_ID_DEFAULT = CameraId + 1,
        FrameRate = CAMERA_ID_DEFAULT + 1,
        FRAME_RATE_DEFAULT = FrameRate + 1,
        EXPOSURE = FRAME_RATE_DEFAULT + 1,
        EXPOSURE_DEFAULT = EXPOSURE + 1,
        VideoType = EXPOSURE_DEFAULT + 1,
        VIDEO_TYPE_DEFAULT = VideoType + 1,
        INTENSITY = VIDEO_TYPE_DEFAULT + 1,
        INTENSITY_DEFAULT = INTENSITY + 1,
        FrameDecimation = INTENSITY_DEFAULT + 1,
        FRAME_DECIMATION_DEFAULT = FrameDecimation + 1,
        MINIMUM_SEGMENT_LENGTH = FRAME_DECIMATION_DEFAULT + 1,
        MINIMUM_SEGMENT_LENGTH_DEFAULT = MINIMUM_SEGMENT_LENGTH + 1,
        MAXIMUM_SEGMENT_LENGTH = MINIMUM_SEGMENT_LENGTH_DEFAULT + 1,
        MAXIMUM_SEGMENT_LENGTH_DEFAULT = MAXIMUM_SEGMENT_LENGTH + 1,
        WINDOW_EXTENTS_X = MAXIMUM_SEGMENT_LENGTH_DEFAULT + 1,
        WINDOW_EXTENTS_X_DEFAULT = WINDOW_EXTENTS_X + 1,
        WINDOW_EXTENTS_X_END = WINDOW_EXTENTS_X_DEFAULT + 1,
        WINDOW_EXTENTS_X_END_DEFAULT = WINDOW_EXTENTS_X_END + 1,
        WINDOW_EXTENTS_Y = WINDOW_EXTENTS_X_END_DEFAULT + 1,
        WINDOW_EXTENTS_Y_DEFAULT = WINDOW_EXTENTS_Y + 1,
        WINDOW_EXTENTS_Y_END = WINDOW_EXTENTS_Y_DEFAULT + 1,
        WINDOW_EXTENTS_Y_END_DEFAULT = WINDOW_EXTENTS_Y_END + 1,
        RESET_FRAME_COUNT = WINDOW_EXTENTS_Y_END_DEFAULT + 1,
        USER_HWND = RESET_FRAME_COUNT + 1,
        MULTICAM = USER_HWND + 1,
        MULTICAM_MASTER = MULTICAM + 1,
        MULTICAM_GROUP_NOTIFY = MULTICAM_MASTER + 1,
        NumericDisplayOn = MULTICAM_GROUP_NOTIFY + 1,
        NumericDisplayOff = NumericDisplayOn + 1,
        SEND_FRAME_MASK = NumericDisplayOff + 1,
        TextOverlayOption = SEND_FRAME_MASK + 1,
        USER_DEF1 = TextOverlayOption + 1,
        SCORING_ENABLED = USER_DEF1 + 1,
        GRAYSCALE_DECIMATION = SCORING_ENABLED + 1,
        OBJECT_CAP = GRAYSCALE_DECIMATION + 1
    }

    enum NPVideoTypeOption
    {
        ProcessedPC = 0,
        RawGrayscale = 1,
        ProcessedCamera = 2
    }

    [Flags]
    enum NPTextOverlayOption
    {
        Header = 0x1,
	    Object = 0x2,
	    ObjectHighlight = 0x4
    }

    static class NPThreshold
    {
        public const int Min = 1;
        public const int Max = 253;
    }
leith
Posts: 194
Joined: Tue Jan 02, 2007 2:17 pm

Re: NP enumerations in c#

Post by leith »

Thanks, that's awesome.

I also noticed that you can extract the #defines from the c++ header files and pretty much copy and paste. the syntax for most of them is compatible. Looks like you might have done that for a lot of it already though.
hpcv
Posts: 58
Joined: Tue Oct 23, 2007 2:09 pm

Re: NP enumerations in c#

Post by hpcv »

Yeah, C# coding standards are different than C++, so I made a start on decapitalizing the names. I wrapped everything into C# enums, but unfortunately, that means you have to typecast the enum to an int before you pass it to a function from the OptiTrack API...
amir
Posts: 11
Joined: Wed Oct 31, 2007 11:12 am

Re: NP enumerations in c#

Post by amir »

can u please share any C# code for as a reference, i have some problems to use the cameras from a c# program...
leith
Posts: 194
Joined: Tue Jan 02, 2007 2:17 pm

Re: NP enumerations in c#

Post by leith »

I have posted some code in this thread recently.

http://forum.naturalpoint.com/forum/ubb ... #Post28089

the later code works better than the earlier code.
Striezel
Posts: 7
Joined: Fri Jul 16, 2010 8:27 am

Re: NP enumerations in c#

Post by Striezel »

I tried that too for the NP_OPTION enum, thanks for your wider range of enums!
Post Reply