Comments (4)
Could you write a code that you use to perform detection? I have tried to detect objects when the image dimensions are not multiple of 16, but the algorithm works fine. So I think that you could incorrect use Simd::Detection.
from simd.
This is pretty much it:
#include "simd/src/Simd/SimdDetection.hpp"
#include "simd/src/Simd/SimdDrawing.hpp"
typedef Simd::DetectionSimd::Allocator Detection;
// set to false for no debug output
bool debug_active = false;
void Debug(const char *s)
{
if (debug_active)
{
printf("%s\n", s);
}
}
extern "C" long InitDetection(char *detectionPath, int pictureWidth, int pictureHeight)
{
// create detection object
Detection *detection = new Detection();
// attempt to load detection
if (detection->Load(detectionPath))
{
// load of detection ok, create size object
Detection::Size size;
Detection::Size size_min;
size.x = pictureWidth;
size.y = pictureHeight;
if (detection->Init(size))
{
// all ok, return pointer to created detection object
return (long) detection;
}
else
{
Debug("InitDetection: Failed to init detection.");
}
}
else
{
Debug("InitDetection: Failed to load detection.");
}
// load of detection failed
// remove detection, and return 0
delete detection;
return 0;
}
extern "C" int CloseDetection(long detectionObject)
{
extern "C" int CalcDetection(long detectionObject, int pictureWidth, int pictureHeight, void* pictureData, int* results)
{
// get detection object
Detection detection = (Detection) detectionObject;
// return -1 if Detect fails
int found = -1;
// clear results
memset(results, -1, 4 * MAX_RESULTS * sizeof(int));
// create view object from image data
Detection::View *image = new Detection::View(pictureWidth, pictureHeight, Detection::View::Format::Gray8, pictureData, 16);
Detection::Objects objects;
if (detection->Detect(*image, objects))
{
Debug("CalcDetection: Detect returned ok.");
// set number of objects found
found = objects.size();
// make results array
for (size_t i = 0; (i < objects.size()) && (i < MAX_RESULTS); ++i)
{
*results++ = objects[i].rect.left;
*results++ = objects[i].rect.top;
*results++ = objects[i].rect.right;
*results++ = objects[i].rect.bottom;
}
// only for debug purposes
if (debug_active)
{
// display number of found objects
char s[80];
sprintf(s, "CalcDetection: Found %i objects.", (int)objects.size());
Debug(s);
// draw rectangle around hits
for (size_t i = 0; i < objects.size(); ++i)
Simd::DrawRectangle(*image, objects[i].rect, uint8_t(255));
// save output
if (image->Save("output.pgm"))
{
Debug("CalcDetection: Save ok.");
}
}
}
else
{
Debug("CalcDetection: Failed to perform calculation.");
}
// remove view object
delete image;
// return number of objects found, -1 if error
return found;
}
from simd.
You have a mistake at this line:
Detection::View *image = new Detection::View(pictureWidth, pictureHeight, Detection::View::Format::Gray8, pictureData, 16);
This constructor creates a Simd::View with given alignment but original image doesn't have the same one.
Better way is using another constructor to create Simd::View:
Detection::View *image = new Detection::View(pictureWidth, pictureHeight, pictureWidth, Detection::View::Format::Gray8, pictureData);
from simd.
Thank, this solves my problem, closing the issue.
from simd.
Related Issues (20)
- Question about shift detector HOT 5
- question about cascade facedetect HOT 2
- SimdBaseUyvyToBgr.cpp compile error VS 2022 HOT 7
- Simd::Resize confusing results HOT 4
- Build error AdvancedVectorExtensions512 HOT 1
- [Feature Request] full TGA version 2 palette loading and 16 bit bitfield Rgb565/Argb1555 support HOT 1
- some question warp_perspective?
- AVX2 Resize assertion HOT 1
- Build error on windows with clang HOT 5
- armV8 gcc compiler auto-vectorization faster than Neon Intrinsics
- Assessment of the difficulty in porting CPU architecture for Simd HOT 1
- InitLevels in SimdDetection seems inefficient HOT 1
- LNK2038 and LNK2005 Error when trying to link a dynamic library that was compiled statically HOT 3
- ARMv7 linking issue HOT 5
- Documentation missing HOT 1
- SimdYuva420pToBgraV2 HOT 2
- Can not compile the SIMD project in Windows for ARM64, using Cmake. HOT 2
- UYVY422 to YUV420p conversation HOT 2
- Console window pops up when using Simd library on Windows in GUI application HOT 3
- No neon instructions used after compiling for ARM HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simd.