Comments (19)
Can you remove all "new CvPoint2D32f(x,y)" can see if that works?
Original comment by [email protected]
on 15 Jan 2011 at 5:45
from javacv.
Well, that was a good suggestion! My Junit test now works and matches the C++
results.
I still, for some reason, am getting all NaN in my live application, but
hopefully I will find the source of the problem. More test loops to be
written, I guess.
I guess I was TOO Java-like in my array creation. However, the code I
originally wrote corresponds closely with the C++ version by instantiating
CvPoint2D32f and pushing it onto a vector.
Thanks again for the useful response!
Ed
Original comment by [email protected]
on 15 Jan 2011 at 9:46
from javacv.
Found another instance of instantiating CvPoint3D32f in an alternate way of
creating the CvPOSITObject.
Now I am getting valid transforms.
This issue can be closed - it is not a defect, although lack of good
documentation is a real concern.
I am not clear if this is a common problem with using JavaCV or just with this
particular method.
Original comment by [email protected]
on 15 Jan 2011 at 9:59
from javacv.
Yes, it's quite confusing, but this is how JNA works... I had no choice for
JavaCV when using JNA, but I will be moving away from JNA, and it should make
it more consistent and less error prone I think. We will see...
Original comment by [email protected]
on 16 Jan 2011 at 1:49
- Changed state: Done
from javacv.
I didn't get it, should "new CvPoint2D32f(x,y)" be replaced by what? I tried
with cvPoint2D32f() but the same result, below are my codes which returns all
"NaN":
CvPoint3D32f[] points = CvPoint3D32f.createArray(4);
points[0] = cvPoint3D32f(0, 0, 0);
points[1] = cvPoint3D32f(4, 2, 0);
points[2] = cvPoint3D32f(0, 0, 8);
points[3] = cvPoint3D32f(0, 2, 8);
CvPoint2D32f[] imagePoints = CvPoint2D32f.createArray(4);
imagePoints[0] = cvPoint2D32f(0, 0);
imagePoints[1] = cvPoint2D32f(228, -216);
imagePoints[2] = cvPoint2D32f(-309, -273);
imagePoints[3] = cvPoint2D32f(-311, -378);
CvPOSITObject obj = cvCreatePOSITObject(points, 4);
CvTermCriteria criteria = cvTermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER,
100, 1.0e-4f);
float[] rotationMatrix = new float[9];
float[] transitionVector = new float[3];
cvPOSIT(obj, imagePoints, 5, criteria.byValue(), rotationMatrix,
transitionVector);
for (int i = 0; i < rotationMatrix.length; i++) {
System.out.println(rotationMatrix[i]);
}
for (int i = 0; i < transitionVector.length; i++) {
System.out.println(transitionVector[i]);
}
cvReleasePOSITObject(obj.pointerByReference());
Original comment by [email protected]
on 28 Jan 2011 at 3:37
from javacv.
It seems that after doing the "createArray", the point records are already
created.
So you want to do "points[0].set(0,0,0)" and so on.
Same with imagePoints[3].set(-311,-378) for example.
As I responded, it is just not clear, but if you look at how the array is
created, it makes a bit of sense - the C++ stuff expects the array elements to
be contiguously allocated.
Original comment by [email protected]
on 28 Jan 2011 at 4:55
from javacv.
[deleted comment]
from javacv.
[deleted comment]
from javacv.
It makes sense, unfortunately I still saw only "NaN" after making the change
(see below). Can you post a sample code that works?
CvPoint3D32f[] points = CvPoint3D32f.createArray(4);
points[0].set(0, 0, 0);
points[1].set(4, 2, 0);
points[2].set(0, 0, 8);
points[3].set(0, 2, 8);
CvPoint2D32f[] imagePoints = CvPoint2D32f.createArray(4);
imagePoints[0].set(0, 0);
imagePoints[1].set(228, -216);
imagePoints[2].set(-309, -273);
imagePoints[3].set(-311, -378);
CvPOSITObject obj = cvCreatePOSITObject(points, 4);
CvTermCriteria criteria = cvTermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER,
100, 1.0e-4f);
float[] rotationMatrix = new float[9];
float[] transitionVector = new float[3];
cvPOSIT(obj, imagePoints, 5, criteria.byValue(), rotationMatrix,
transitionVector);
for (int i = 0; i < rotationMatrix.length; i++) {
System.out.println(rotationMatrix[i]);
}
for (int i = 0; i < transitionVector.length; i++) {
System.out.println(transitionVector[i]);
}
cvReleasePOSITObject(obj.pointerByReference());
Original comment by [email protected]
on 29 Jan 2011 at 12:55
from javacv.
If I use a focal length of 500 instead of 5, I get other values than NaN.. are
they valid?
Original comment by [email protected]
on 29 Jan 2011 at 1:24
from javacv.
You're right, in this way it works. I was using 5 because the focal length was
unknown, however the rotation matrix result differs while focal length changes,
then how to choose a reasonable value as focal length? It's not a problem of
javacv of course.
Original comment by [email protected]
on 29 Jan 2011 at 1:48
from javacv.
I don't understand how the focal length comes into it either. The math relies
on it heavily, however, as it affects the perspective projection. Camera
calibration programs (some included in OpenCV) will derive this value, but I
have never understood what units are expected in POSIT. I believe it is in the
same units as the model coordinates, but might be in pixels. I am using it
with a Wii camera which cannot be easily calibrated - the generally published
value is 1300 or 1380 for that.
Original comment by [email protected]
on 29 Jan 2011 at 5:30
from javacv.
The unit of focal length should be in pixel, because focal length equals to
physical focal length (mm) multiplied by density of pixels (pixels per mm).
Original comment by [email protected]
on 30 Jan 2011 at 1:37
from javacv.
I guess this needs to be reopened, as POSIT fails to work with the cpp version
of JavaCV along with OpenCV 2.2. The code that worked for the older version of
JavaCV had to be refactored to use things like points.position(i).set(0,0,10).
This appears to do the proper thing when I read the data back, but calling
cvPOSIT again produces NaN results regardless of input. A C++ test of the same
data using OpenCV 2.2 produces correct results. I can supply a test case if
necessary, but perhaps someone knows what else has changed in sending a vector
or array of CvPoint2D32F and CvPoint3D23F to cvPOSIT. The problem could be
anywhere, perhaps in the creation of the CvPOSITObject which is opaque and
somewhat difficult to investigate.
Original comment by [email protected]
on 11 May 2011 at 6:27
from javacv.
You do call points.position(0) before calling cvPOSIT() right? If so, can you
provide your test case? thanks
Original comment by [email protected]
on 11 May 2011 at 6:30
from javacv.
I'll try to put together a simplified test case (right now it is part of a set
of JUnit tests and some possibly proprietary code). Maybe my test case will
just work :)
Yes, I am using the weird points.position(i).set and so on, and have verified
that I can get the correct values back. I can't do much with CvPOSITObject once
it is created since it is opaque. I find it difficult to debug at the C++
level when running from JavaCV - I have done so in the distant past, but am
unsure how to do it at the moment.
If it matters, I am running on Ubuntu 10.10 32 bit.
Thanks for the great project. I have tried following the source, but don't see
anything wildly different from other stuff that does appear to work.
Original comment by [email protected]
on 11 May 2011 at 9:13
from javacv.
Here is a test program. It produces NaN for all results. Interestingly, when
creating and debugging it, the first "successful" run produced actual numbers
for the translation, although I think they were wrong. Ever since, I get NaN :)
The results from the C++ version of this are:
-.- ESTIMATED POSE
0.707107 | 0 | 0.707107 | 0
0.5 | 0.707107 | -0.5 | 0
-0.5 | 0.707107 | 0.5 | 100
0 | 0 | 0 | 1
Where 0,0,100 is the translation vector.
Original comment by [email protected]
on 11 May 2011 at 11:02
Attachments:
from javacv.
Apparently, I need to use point.position(0) as the argument in all the calls
- input and output! That is certainly not clear from usage elsewhere.
The calls:
positObj = CvPOSITObject.create(targetPoints.position(0),nPoints);
and
cvPOSIT(positObj, cvImagePoints.position(0), focalLength, criteria,
rotationMatrix,
translationVector);
do the trick.
Ohhh - did you mean that I have to actually "position" the points object
before the call?
Weird - it does remember the last position used, doesn't it? Boy, I wish
there was real usage documentation going on here!
Ed
Original comment by [email protected]
on 12 May 2011 at 12:36
from javacv.
Works if
targetPoints.position(0);
cvImagePoints.position(0);
is added after initialization and before using.
Original comment by [email protected]
on 12 May 2011 at 1:07
from javacv.
Related Issues (20)
- Android arm7 libavutil.so "not found" HOT 9
- This GMM Class occured NullPointerException at Native Method HOT 2
- could not create camera capture HOT 7
- FacePreview apk is not working on Samsung mobile having android version 2.2 HOT 14
- Unable to create the video from images by using latest java cv update .. HOT 9
- how to use javacv with method like cvNormalize and cvDrawContours ? HOT 1
- How to add the "Sample Descriptions in Video while creating from the images "? HOT 3
- could not find class FFmpegFrameGrabber on Android HOT 2
- FFmpeg decoding_encoding.c sample HOT 3
- Should split FFmpeg part to JavaFFmpeg HOT 3
- OpenCV Error: Bad argument at cvGetReal1D, cvQueryHistValue_1D HOT 1
- Bad allocation error on multithreaded opencv_highgui.cvLoadImageM HOT 10
- Problems use Stitcher HOT 1
- Using for FFmpeg HOT 1
- When I use "new FFmpegFrameRecorder" instead of "FFmpegFrameRecorder.creatDefault", the Exception occur. HOT 8
- Confidence value at FaceRecognition returns invalid values HOT 13
- Linker errors when building on Mac or Windows (undefined/unresolved symbol: JNI_CreateJavaVM) HOT 6
- error when calling cvCreateFileCapture HOT 1
- Patch for /samples/FaceRecognition.java HOT 3
- Android Images to video how to change the video size dynamically as per orientation ?
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 javacv.