-
Notifications
You must be signed in to change notification settings - Fork 104
Psi
After building Psi from source, I have the folders/files in the image.
If I make a new project in the Psi solution, how do I use Psi components? I tried using Microsoft.Psi in the default Program.cs of a basic Console App, but the compiler can't find the Microsoft.Psi package. Are there any tutorial videos that go through developing after building from source?
All reactions
Replies: 2 comments 10 replies
You'll need to first add Microsoft.Psi (and any other class libraries of components you might need) as "Project References" to your project. In Visual Studio, this can be done by right-clicking on your new project, selecting "Add -> Project Reference..."
For example, once you've added the Microsoft.Psi project reference, your new project's .csproj file will look something like the following:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Sources\Runtime\Microsoft.Psi\Microsoft.Psi.csproj" />
</ItemGroup>
</Project>
All reactions
Thank you. I followed your instructions and added these items to the .csproj:
<ItemGroup>
<ProjectReference Include="..\Sources\Imaging\Microsoft.Psi.Imaging\Microsoft.Psi.Imaging.csproj" />
<ProjectReference Include="..\Sources\RealSense\Microsoft.Psi.RealSense.Windows.x64\Microsoft.Psi.RealSense.Windows.x64.csproj" />
<ProjectReference Include="..\Sources\RealSense\Microsoft.Psi.RealSense_Interop.Windows.x64\Microsoft.Psi.RealSense_Interop.Windows.x64.vcxproj" />
<ProjectReference Include="..\Sources\Runtime\Microsoft.Psi.Interop\Microsoft.Psi.Interop.csproj" />
<ProjectReference Include="..\Sources\Runtime\Microsoft.Psi.Windows\Microsoft.Psi.Windows.csproj" />
<ProjectReference Include="..\Sources\Runtime\Microsoft.Psi\Microsoft.Psi.csproj" />
</ItemGroup>
I ran a simple code snippet:
using System;
using Microsoft.Psi;
using Microsoft.Psi.RealSense.Windows;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var p = Pipeline.Create();
RealSenseSensor r = new(p);
//r.ColorImage.Do(t => Console.WriteLine(t));
p.RunAsync();
Console.ReadKey();
p.Dispose();
}
}
}
but I get the following error:
I have the correct reference in the .csproj (I believe?).
Why might this error be occurring?
All reactions
This error usually indicates a mismatch in the project's platform target settings. The RealSense component is x64 only, so your project's Platform target also needs to be x64, as shown below:
image
All reactions
I built that, but it did not fail.
All reactions
I don't have any other good suggestions. The Psi team probably have better insight into it.
If you are open to trying other random debugging tricks, here's some things I would try/validate:
- Delete the bin/obj folder in your project directory and rebuild. See if it works after that.
- Check if the
dllfile is in same folder as your generated bin file. The path should be likePROJECT/bin/debug/net472/. If its not there, try copying it from the other folders.
All reactions
Could you also try modifying your .csproj file as follows (replacing/deleting AnyCPU):
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
<Platforms>x64</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Sources\Imaging\Microsoft.Psi.Imaging\Microsoft.Psi.Imaging.csproj" />
<ProjectReference Include="..\Sources\RealSense\Microsoft.Psi.RealSense.Windows.x64\Microsoft.Psi.RealSense.Windows.x64.csproj" />
<ProjectReference Include="..\Sources\RealSense\Microsoft.Psi.RealSense_Interop.Windows.x64\Microsoft.Psi.RealSense_Interop.Windows.x64.vcxproj" />
<ProjectReference Include="..\Sources\Runtime\Microsoft.Psi.Interop\Microsoft.Psi.Interop.csproj" />
<ProjectReference Include="..\Sources\Runtime\Microsoft.Psi.Windows\Microsoft.Psi.Windows.csproj" />
<ProjectReference Include="..\Sources\Runtime\Microsoft.Psi\Microsoft.Psi.csproj" />
</ItemGroup>
</Project>
All reactions
I did this, but the same issue occurs.
All reactions
I don't have any other good suggestions. The Psi team probably have better insight into it.
If you are open to trying other random debugging tricks, here's some things I would try/validate:
- Delete the bin/obj folder in your project directory and rebuild. See if it works after that.
- Check if the
dllfile is in same folder as your generated bin file. The path should be likePROJECT/bin/debug/net472/. If its not there, try copying it from the other folders.
1: Tried, but no luck.
2: There is no debug folder in PROJECT/bin. Is that an issue?