Browse Source

update to latest intel sdk. doesnt seem to make things better. fuck you intel.

Florian Mueller 7 years ago
parent
commit
eda03d2090

BIN
.vs/bbiwarg/v14/.suo


+ 125 - 0
bbiwarg/Input/InputProviding/HackyInputProviderIntel.cs

@@ -0,0 +1,125 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.ExceptionServices;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace BBIWARG.Input.InputProviding
+{
+    class HackyInputProviderIntel : MarshalByRefObject, IInputProvider
+    {
+        private bool shouldRun;
+        public int startId;
+
+        public int CurrentFrameID
+        {
+            get;
+            set;
+        }
+
+        public float FieldOfViewHorizontal
+        {
+            get;
+            set;
+        }
+
+        public float FieldOfViewVertical
+        {
+            get;
+            set;
+        }
+
+        public int ImageWidth
+        {
+            get { return 640; }
+        }
+
+        public int ImageHeight
+        {
+            get { return 480; }
+        }
+
+        public bool IsActive
+        {
+            get;
+            set;
+        }
+
+        public UInt16 lowConfidenceValue;
+
+        public event DeviceStartedEventHandler DeviceStartedEvent;
+        public event NewFrameEventHandler NewFrameEvent;
+
+        public void initialize()
+        {
+            CurrentFrameID = 0;
+        }
+
+        public void start()
+        {
+            shouldRun = true;
+            if (DeviceStartedEvent != null)
+            {
+                DeviceStartedEvent(this, new EventArgs());
+                DeviceStartedEvent = null; //only notify once...
+            }
+
+            IntelDomainWrapper wrapper = null;
+
+            while (shouldRun) {
+                if (wrapper == null || wrapper.errorstate) {//plus timestamp
+                    //time to start a new one!
+                    wrapper = new IntelDomainWrapper(this);
+                    Task runCamTask = new Task(wrapper.run);
+
+                    var timeoutCancellationTokenSource = new CancellationTokenSource();
+                    
+                }
+            }
+        }
+
+        public void stop()
+        {
+            shouldRun = false;
+        }
+
+    }
+
+    class IntelDomainWrapper {
+        private AppDomain domain;
+        private IntelCameraWrapper wrapper;
+
+        public bool errorstate = false;
+        private HackyInputProviderIntel inputProvider;
+
+        public IntelDomainWrapper(HackyInputProviderIntel inputProvider) {
+            this.inputProvider = inputProvider;
+        }
+
+        [HandleProcessCorruptedStateExceptions]
+        public void run() {
+            domain = System.AppDomain.CreateDomain("AppDomain-" + inputProvider.startId);
+            inputProvider.startId++;
+
+            wrapper = (IntelCameraWrapper)domain.CreateInstanceAndUnwrap(typeof(IntelCameraWrapper).Assembly.GetName().ToString(), typeof(IntelCameraWrapper).FullName);
+            //wrapper.init(inputProvider);
+
+            inputProvider.IsActive = true;
+
+            try
+            {
+                wrapper.run();
+            }
+            catch (System.AccessViolationException)
+            {
+                Console.WriteLine("Camera caused corrupted process state.");
+                errorstate = true;
+            }
+
+
+        }
+
+    }
+}

+ 28 - 15
bbiwarg/Input/InputProviding/InputProviderIntel.cs

@@ -5,6 +5,7 @@ using System.Timers;
 using System.Threading;
 using System.Diagnostics;
 using System.Runtime.ExceptionServices;
+using System.Threading.Tasks;
 
 namespace BBIWARG.Input.InputProviding
 {
@@ -75,32 +76,44 @@ namespace BBIWARG.Input.InputProviding
         [HandleProcessCorruptedStateExceptions]
         public void start()
         {
+            startTimeWatch = Stopwatch.StartNew();
             Console.WriteLine("starting new AppDomain (" + startId +")...");
             domain = System.AppDomain.CreateDomain("AppDomain-" + startId);
 
             startId++;
 
             wrapper = (IntelCameraWrapper) domain.CreateInstanceAndUnwrap(typeof(IntelCameraWrapper).Assembly.GetName().ToString(), typeof(IntelCameraWrapper).FullName);
-            wrapper.init(this);
 
-            IsActive = true;
+            var startTask = Task.Run(() => wrapper.init(this));
 
-            if (DeviceStartedEvent != null) {
-                DeviceStartedEvent(this, new EventArgs());
-                DeviceStartedEvent = null; //only notify once...
+            if (!startTask.Wait(TimeSpan.FromSeconds(4)))
+            {
+                Console.WriteLine("Timeout during init");
+                errorstate = true;
+                scheduledForRestart = false;
             }
+            else {
+                IsActive = true;
 
-            scheduledForRestart = false;
-            startTimeWatch = Stopwatch.StartNew();
+                if (DeviceStartedEvent != null)
+                {
+                    DeviceStartedEvent(this, new EventArgs());
+                    DeviceStartedEvent = null; //only notify once...
+                }
 
-            try
-            {
-                wrapper.run();
-            }
-            catch (System.AccessViolationException)
-            {
-                Console.WriteLine("Camera caused corrupted process state.");
-                errorstate = true;
+                scheduledForRestart = false;
+
+                try
+                {
+                    wrapper.run();
+                }
+                catch (System.AccessViolationException)
+                {
+                    Console.WriteLine("Camera caused corrupted process state.");
+                    errorstate = true;
+                }
+
+                
             }
 
             checkExitErrorstate();

+ 9 - 0
bbiwarg/bbiwarg.csproj

@@ -218,11 +218,20 @@
     <None Include="App.config">
       <SubType>Designer</SubType>
     </None>
+    <None Include="libpxccpp2c.dll.signature">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Content Include="cudart32_55.dll">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
+    <Content Include="libpxcclr.cs.dll">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="libpxccpp2c.dll">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
     <Content Include="opencv_core290.dll">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>

BIN
bbiwarg/libpxcclr.cs.dll


BIN
bbiwarg/libpxccpp2c.dll


+ 1 - 0
bbiwarg/libpxccpp2c.dll.signature

@@ -0,0 +1 @@
+V±Л—SzМ1§вЛќЋџЭццxFЗй
2:КHG°ЂЅ®•жпцвТf”Луj,НКЩw3Њ6`Xя
љDnиЕпАж$кчqбй‚d¦ИUo»‡S€ЂLг”и‡aЎПyўKРэCiiYљйДКоe<“’¶SLї