dlib: extract_histogram_descriptors inside extract_highdim_face_lbp_descriptors returns vector with zeros - dlib

I'm trying to extract this features, but it is returning a vector with all zeros. I called the function dlib::extract_highdim_face_lbp_descriptors and followed the code and it seems that is extract_histogram_descriptors is what it is returning zeros.
So I hope anyone can help, it would be highly appreciated.
Thanks
This are the important lines of my code:
std::vector features;
dlib::array2d<unsigned char> grayFace;
dlib::assign_image(grayFace, face);
dlib::extract_highdim_face_lbp_descriptors<dlib::array2d<unsigned char>, double>(grayFace, shape, features);
face is an array2D containing the recognized face, shape is of type dlib::full_object_detection.
I have also check that grayFace and shape are correct.

Ok, finally I could solve this problem, I post the answer in case someone has the same problem.
The thing is that as first argument, dlib::extract_highdim_face_lbp_descriptors expects the hole frame image, not just the found face which is what I was given to it.

Related

Get index of an SKPoint in an SKPath

I'm not seeing an IndexOf or FindIndex method for SKPath.Points. I need to be able to get neighbouring points on both sides of a specified point. Path.Iterator only has .Next, so I am looking for using the index of the SKPoint instead.
With IndexOf or FindIndex seemingly missing, I am thinking of inheriting and maintaining a 2nd dataset in the background for getting the index.
Am I missing something obvious? How are others getting the index, so far?
This post helped. Calling IndexOf directly on Array works. Just need to make sure your SKPoint X and Y are unique from other SKPoints stored in the SKPath.Points. It is doing the check based on the SKPoint's position, so if you have multiple SKPoints at (0, 0), for example, it will return the first one at that position.
Luckily, I should never be in the situation for my use case.

term does not evaluate to a function taking 1 arguments

Please have a look at the following OpenCV code
Mat *curent;
current = new Mat();
cv::Rect bRect = cv::boundingRect(Mat(*points).reshape(2));
Mat roi = *current(bRect);
Here, I am trying to get a ROI to the Mat called roi. But whenever I try to get execute the last line of the above code I get the error term does not evaluate to a function taking 1 arguments. I have followed the same technique of getting an ROI without pointers number of times before in C++ and they worked. I guess the issue is with pointer current ? current must be a pointer because local variable slowed the application in an unbelievable way.
So, how can I solve this issue and get the ROI ?
please, throw out those pointers!
you're going to wreck havoc on the internal Mat refcounts, produce undefined behaviour and memleaks
"local variable slowed the application in an unbelievable way."
really, you think, copying a 58 byte struct is the reason ? i just don't believe you.
well i'll give you a hint, anyway - the ( ) operator has a higher precedence than the * operator.

Find crossing lines in drawing engine

i am working on a little multimedia - project in which the user, amongst other things, can draw shapes on a canvas (2d) by connecting points with a line.
but i need to prohibit the user from crossing lines.
what i am looking for would be a small algorithm that can find intersecting lines.
the project is done in AS3/Flash but i guess the answer would be universal.
anyone can give me a clue?
thanks
Here is an example in Java but I think you can easily adapt to AS3 :
public static boolean intersects(double ax, double ay, double bx, double by,
double cx, double cy, double dx, double dy) {
double denum = ((bx-ax)*(dy-cy)-(by-ay)*(dx-cx));
if (denum == 0) return false; // parallel segments
double r = ((ay-cy)*(dx-cx)-(ax-cx)*(dy-cy)) / denum;
double s =
((ay-cy)*(bx-ax)-(ax-cx)*(by-ay)) / denum;
return 0<=r && r<=1 && 0<=s && s<=1;
}
It should return true if the segments [AB] and [CD] intersect.
You can find reference here
You can use the methods Point, hitTest, hitTestObject or hitTestPoint. I don't know if Super Chafouin's answer is helpful, but I believe that the code looks quite different in AS3 though.
To explain what they mean, I'll quote Aaron Beall from actionscript.org, giving a nice explanation:
hitTestObject checks the bounding box rectangle of two display
objects. It always checks rectangle-vs-rectangle.
hitTestPoint checks a point (x,y) against a display object:
- With shapeFlag true it checks point-vs-shape
- With shapeFlag false it checks point-vs-rectangle
BitmapData/hitTest checks a bitmap against a point, rectangle, or
other bitmapdata. Using a check of bitmapdata-vs-bitmapdata means you
can perform alpha channel based shape-vs-shape checks. See here:
http://www.mikechambers.com/blog/200...ion-detection/
(Also, not to nitpick but just to make sure you understand, neither
hitTestObject or hitTestPoint are "triggered" -- you must manually
call them when you want to check something.)
Asking for a whole algorithm is quite something, it depends on your app too.
See for more examples and documentation here, here
I hope this will help!

MATLAB - image huffman encoding

I have a homework in which i have to convert some images to grayscale and compress them using huffman encoding. I converted them to grayscale and then i tried to compress them but i get an error. I used the code i found here.
Here is the code i'm using:
A=imread('Gray\36.png');
[symbols,p]=hist(A,unique(A))
p=p/sum(p)
[dict,avglen]=huffmandict(symbols,p)
comp=huffmanenco(A,dict)
This is the error i get. It occurs at the second line.
Error using eps
Class must be 'single' or 'double'.
Error in hist (line 90)
bins = xx + eps(xx);
What am i doing wrong?
Thanks.
P.S. how can i find the compression ratio for each image?
The problem is that when you specify the bin locations (the second input argument of 'hist'), they need to be single or double. The vector A itself does not, though. That's nice because sometimes you don't want to convert your whole dataset from an integer type to floating precision. This will fix your code:
[symbols,p]=hist(A,double(unique(A)))
Click here to see this issue is discussed more in detail.
first, try :
whos A
Seems like its type must be single or double. If not, just do A = double(A) after the imread line. Should work that way, however I'm surprised hist is not doing the conversion...
[EDIT] I have just tested it, and I am right, hist won't work in uint8, but it's okay as soon as I convert my image to double.

Matlab big matrix

I'm trying to use matlab for the first time but I'm having a problem because the matrix I'm using is too big, I think.. I command I'm trying is:
m=[1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;169201]7;531456;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017]
And I'm getting the following error: Error: Unexpected MATLAB expression.
Does anyone have a solution for this?
Thanks in advance !
That matrix is tiny :-) Matlab can handle millions of elements per matrix.
However, on the second line, you have an extra bracket that ruins things:
...17;1692017;169201 ] 7;5...
Get rid of it, and you'll be fine!
Seems like you are trying to do a matrix, but typing its code wrongly. First, the ; separates lines; if you want to separaate columns in a row you have to use a space.
And you have two closing ], while you have only one opening [ which is clearly incorrect

Resources