Skip to content

Commit

Permalink
Update YoloCSharpWrapper to support batch_size (AlexeyAB#8249)
Browse files Browse the repository at this point in the history
YoloCSharpWrapper `InitializeYolo` declaration now matches the parameters of yolo_v2_class.hpp "init".  Resolves "attempting to read/write corrupted memory" error when calling darknet.dll "detect" methods from C#.
  • Loading branch information
jklemmack authored Nov 23, 2021
1 parent 108dc8b commit 0b2ebb7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/csharp/YoloCSharpWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class YoloWrapper : IDisposable
private const int MaxObjects = 1000;

[DllImport(YoloLibraryName, EntryPoint = "init")]
private static extern int InitializeYolo(string configurationFilename, string weightsFilename, int gpu);
private static extern int InitializeYolo(string configurationFilename, string weightsFilename, int gpu, int batch_size);

[DllImport(YoloLibraryName, EntryPoint = "detect_image")]
private static extern int DetectImage(string filename, ref BboxContainer container);
Expand Down Expand Up @@ -38,9 +38,9 @@ public struct BboxContainer
public bbox_t[] candidates;
}

public YoloWrapper(string configurationFilename, string weightsFilename, int gpu)
public YoloWrapper(string configurationFilename, string weightsFilename, int gpu, int batch_size = 1)
{
InitializeYolo(configurationFilename, weightsFilename, gpu);
InitializeYolo(configurationFilename, weightsFilename, gpu, batch_size);
}

public void Dispose()
Expand Down

0 comments on commit 0b2ebb7

Please sign in to comment.