You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to write a sample to show how to use a track bar. I can create the track bar and display it in a window, but when I click on it I get this exception:
Managed Debugging Assistant 'InvalidVariant' has detected a problem in 'SamplesCS.exe'.
Additional Information: An invalid VARIANT was detected during a conversion from an unmanaged VARIANT to a managed object. Passing invalid VARIANTs to the CLR can cause unexpected exceptions, corruption or data loss.
I don't have experience with going back and forth between unmanaged and managed data. What should I do to avoid this exception?
Here's the code so far:
public class TrackBarSample : ISample
{
public void Run()
{
using var src = Cv2.ImRead(FilePath.Image.Balloon);
const string windowName = "TrackBar Sample";
using var _ = new Window(windowName, WindowMode.Normal);
var trackBarValue = 256;
var trackBarRed = Cv2.CreateTrackbar("red", windowName, ref trackBarValue, 511, OnTrackBarChange);
Cv2.ImShow(windowName, src);
Cv2.WaitKey(0);
}
private void OnTrackBarChange(int pos, object userData)
{
Debug.WriteLine($"track bar: {pos} object: {userData}");
}
}
The text was updated successfully, but these errors were encountered:
I'm trying to write a sample to show how to use a track bar. I can create the track bar and display it in a window, but when I click on it I get this exception:
I don't have experience with going back and forth between unmanaged and managed data. What should I do to avoid this exception?
Here's the code so far:
The text was updated successfully, but these errors were encountered: