Fix NV12 crash issue when recreate camera object
(new structure) does not work
This commit is contained in:
@@ -14,6 +14,7 @@ set(ANSOD_SOURCES
|
||||
ANSFaceDetectorEngine.cpp
|
||||
ANSFaceRecognizerEngine.cpp
|
||||
ANSGpuFrameRegistry.cpp
|
||||
GpuNV12SlotPool.cpp
|
||||
ANSONNXCL.cpp
|
||||
ANSONNXOBB.cpp
|
||||
ANSONNXPOSE.cpp
|
||||
|
||||
23
modules/ANSODEngine/GpuNV12SlotPool.cpp
Normal file
23
modules/ANSODEngine/GpuNV12SlotPool.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
// GpuNV12SlotPool.cpp — Cross-DLL singleton resolver for ANSODEngine.dll.
|
||||
//
|
||||
// Finds the canonical GpuNV12SlotPool instance exported by ANSCV.dll
|
||||
// via GetProcAddress. No link dependency on ANSCV.lib needed.
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
#include "GpuNV12SlotPool.h"
|
||||
|
||||
GpuNV12SlotPool* GpuNV12SlotPool::resolveProcessWide() {
|
||||
// ANSCV.dll is always loaded before inference starts (it provides RTSP).
|
||||
HMODULE hMod = GetModuleHandleA("ANSCV.dll");
|
||||
if (hMod) {
|
||||
typedef GpuNV12SlotPool* (*GetInstanceFn)();
|
||||
auto fn = reinterpret_cast<GetInstanceFn>(
|
||||
GetProcAddress(hMod, "GpuNV12SlotPool_GetInstance"));
|
||||
if (fn) return fn();
|
||||
}
|
||||
// Fallback: local instance (unit tests without ANSCV.dll).
|
||||
static GpuNV12SlotPool local;
|
||||
return &local;
|
||||
}
|
||||
@@ -276,6 +276,7 @@ namespace ANSCENTER {
|
||||
const bool useZeroCopy = isCudaDevice && gpuMatch;
|
||||
|
||||
// --- Debug: log pointer state before reading ---
|
||||
#if defined(ANSCORE_GPU_DEBUG) && ANSCORE_GPU_DEBUG
|
||||
{
|
||||
char _nv12_dbg[512];
|
||||
snprintf(_nv12_dbg, sizeof(_nv12_dbg),
|
||||
@@ -294,6 +295,7 @@ namespace ANSCENTER {
|
||||
#endif
|
||||
fprintf(stderr, "%s", _nv12_dbg);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Effective plane pointers — for zero-copy, use CUDA device ptrs;
|
||||
// for CPU upload, use the CPU snapshot buffers.
|
||||
@@ -362,7 +364,7 @@ namespace ANSCENTER {
|
||||
cv::cuda::GpuMat gpuY, gpuUV;
|
||||
|
||||
if (useZeroCopy) {
|
||||
// CUDA zero-copy: wrap NVDEC device pointers directly
|
||||
// CUDA zero-copy: wrap pool buffer device pointers directly
|
||||
gpuY = cv::cuda::GpuMat(frameH, frameW, CV_8UC1,
|
||||
effYPlane, static_cast<size_t>(effYLinesize));
|
||||
gpuUV = cv::cuda::GpuMat(frameH / 2, frameW, CV_8UC1,
|
||||
@@ -455,6 +457,7 @@ namespace ANSCENTER {
|
||||
gpuResized.create(inputH, inputW, CV_8UC3);
|
||||
|
||||
cudaStream_t rawStream = cv::cuda::StreamAccessor::getStream(stream);
|
||||
#if defined(ANSCORE_GPU_DEBUG) && ANSCORE_GPU_DEBUG
|
||||
{
|
||||
char _nv12_dbg2[256];
|
||||
snprintf(_nv12_dbg2, sizeof(_nv12_dbg2),
|
||||
@@ -467,6 +470,7 @@ namespace ANSCENTER {
|
||||
#endif
|
||||
fprintf(stderr, "%s", _nv12_dbg2);
|
||||
}
|
||||
#endif
|
||||
launcher(gpuY, gpuUV, gpuResized, frameW, frameH, inputW, inputH, rawStream);
|
||||
|
||||
stream.waitForCompletion();
|
||||
|
||||
Reference in New Issue
Block a user