Skip to content

Commit

Permalink
Updates project file to net8.0, replacing video device enumeration co…
Browse files Browse the repository at this point in the history
…de from SharpDX.MediaFoundation and DirectShowLib with Microsoft.Windows.CsWin32

The former package is no longer compatible with .net8 (needs awkward hacks in build system as well as current vvvv runtime code), the latter causes build warnings.
  • Loading branch information
azeno committed Nov 5, 2024
1 parent f2757e2 commit 43375a9
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 86 deletions.
25 changes: 13 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@

# .v4p backup files
*~.xml

# Dynamic plugins .dll
bin/
obj/
.vs/
packages/
lib/net461/
appveyor/nuget.exe
/lib/net472/

# .v4p backup files
*~.xml

# Dynamic plugins .dll
bin/
obj/
.vs/
packages/
lib/net461/
appveyor/nuget.exe
/lib/net472/
/lib/net8.0-windows/

/.vl/*
2 changes: 1 addition & 1 deletion VL.OpenCV.vl
Original file line number Diff line number Diff line change
Expand Up @@ -49097,7 +49097,7 @@
<Pin Id="Mrou8fkpIQtLSG8SpOrYsW" MergeId="19725" Name="Rejected Areas" Kind="OutputPin" Bounds="503,958" Summary="Contains the Points of those squares whose inner code has not a correct codification. Useful for debugging purposes." />
</Patch>
</Patch>
<PlatformDependency Id="M1N4SojOni0Osyx2gZ4x10" Location="./lib/net472/VL.OpenCV.dll" />
<PlatformDependency Id="M1N4SojOni0Osyx2gZ4x10" Location="./lib/net8.0-windows/VL.OpenCV.dll" />
<PlatformDependency Id="UrxLbPlbKmVP94Zx5YWsQo" Location="System" />
<PlatformDependency Id="KKd4psddv1PM1JDnyYS5Lv" Location="System.Drawing" />
<PlatformDependency Id="Ee0UUmfqOVWPSXM6OSY7rA" Location="System.Windows.Forms" />
Expand Down
11 changes: 6 additions & 5 deletions src/Dynamic Enums/VideoInput/VideoInputDeviceDefinition.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using SharpDX.MediaFoundation;
using System;
using System;
using System.Collections.Generic;
using VL.Lib;
using VL.Lib.Collections;
using static Windows.Win32.PInvoke;

namespace VL.OpenCV
{
Expand All @@ -12,21 +12,22 @@ namespace VL.OpenCV
public class VideoInputDeviceDefinition : DynamicEnumDefinitionBase<VideoInputDeviceDefinition>
{
//return the current enum entries
protected override IReadOnlyDictionary<string, object> GetEntries()
protected override unsafe IReadOnlyDictionary<string, object> GetEntries()
{
// Get the collection of video devices
Activate[] capDevices = VideoInInfo.EnumerateVideoDevices();
var capDevices = VideoInInfo.EnumerateVideoDevices();
Dictionary<string, object> devices = new Dictionary<string, object>(capDevices.Length);
for (int i = 0; i < capDevices.Length; i++)
{
var j = 1;
var friendlyName = capDevices[i].Get(CaptureDeviceAttributeKeys.FriendlyName);
var friendlyName = VideoInInfo.GetString(capDevices[i], in MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME);
var finalName = friendlyName;
while (devices.ContainsKey(finalName))
{
finalName = friendlyName + " #" + j++;
}
devices[finalName] = i;
capDevices[i]->Release();
}
return devices;
}
Expand Down
6 changes: 6 additions & 0 deletions src/NativeMethods.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://aka.ms/CsWin32.schema.json",
"allowMarshaling": false,
"comInterop": { "preserveSigMethods": [ "IAMCameraControl", "IAMVideoProcAmp", "IMFMediaEngine", "ICreateDevEnum" ] },
"public": true
}
20 changes: 20 additions & 0 deletions src/NativeMethods.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CoCreateInstance
IMFActivate
IMFMediaSource
MFCreateAttributes
MFEnumDeviceSources
MFMediaType_Video
MF_MT_SUBTYPE
MF_MT_FRAME_RATE
MF_MT_FRAME_SIZE
MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME
MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE
MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID

ICreateDevEnum
IPropertyBag
CLSID_SystemDeviceEnum
CLSID_VideoInputDeviceCategory
VariantInit
VariantClear
S_OK
40 changes: 8 additions & 32 deletions src/VL.OpenCV.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,32 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<ProjectGuid>{BF6BC14C-CC1F-4F5F-B491-452662B4D4A1}</ProjectGuid>
<RootNamespace>VL.OpenCV</RootNamespace>
<AssemblyName>VL.OpenCV</AssemblyName>
<TargetFramework>net472</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<OutputPath>..\lib\</OutputPath>
<Version>2.5.0</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Version>3.0.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn>1701;1702;MSB3270;MSB3026</NoWarn>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Remove="packages\**" />
<EmbeddedResource Remove="packages\**" />
<None Remove="packages\**" />
</ItemGroup>
<ItemGroup>
<Reference Include="FeralTic">
<HintPath>..\lib\dx11\FeralTic.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Management" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="VVVV.DX11.Core">
<HintPath>..\lib\dx11\VVVV.DX11.Core.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DirectShowLib" Version="1.0.0" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.46-beta">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="OpenCvSharp4.Extensions" Version="4.9.0.20240103" />
<PackageReference Include="OpenCvSharp4.Windows" Version="4.9.0.20240103" />
<PackageReference Include="SharpDX.MediaFoundation" Version="4.2.0" />
<PackageReference Include="VL.Core" Version="2021.4.8" />
<PackageReference Include="SharpDX" Version="4.2.0" />
<PackageReference Include="VL.Core" Version="2024.6.6" />
</ItemGroup>

</Project>
Loading

0 comments on commit 43375a9

Please sign in to comment.