I have a question concerning javaCVs FlannBasedMatcher. In the openCV documentation, it is possible to supply an index / search parameter to the constructor, in java it doesn't work. So how can i do it if not via the constructor?
FlannBasedMatcher flannMatcher = new FlannBasedMatcher(indexParams, searchParams); // Doesn't work for me
Ok so the lines that enable the constructor to use the index- and searchParameters were commented out. The new release of javaCV will have that constructor as well!
Related
I am working on a Java binding for the excellent libvips
Using this function all is fine:
VipsImage *in;
in = vips_image_new_from_file( test.jpg, NULL )
vips_image_write_to_file( in, "out.jpg", NULL )
So mapped in Java:
Pointer vips_image_new_from_file(String filename,String params);
But I have a problem when the parameter like this:
VipsImage *in;
VipsImage *out;
vips_invert( in, &out, NULL )
vips_image_write_to_file( out, "out.jpg", NULL )
I have tried:
int vips_resize(Pointer in, PointerByReference out, Double scale, String params);
Pointer in = vips_image_new_from_file("file.png",null);
PointerByReference ptr1 = new PointerByReference();
vips_invert(in, ptr1, null);
vips_image_write_to_file( ptr1.getValue(), "fileout.png", null);
But doesn't work. The ptr1.getValue() does not contains the expected result.
How can I do it?
Thanks
I'm the libvips maintainer, a Java binding would be great!
But I think you might be taking the wrong approach. I think you are trying a straight wrap of the C API, but that's going to be tricky to do well, since it makes use of a lot of C-isms that don't map well to Java. For example, in C you can write:
VipsImage *image;
if (!(image = vips_image_new_from_file("somefile.jpg",
"shrink", 2,
"autorotate", TRUE,
NULL)))
error ...;
ie. the final NULL marks the end of a varargs name / value list. Here I'm asking the jpeg loader to do a x2 shrink during load, and to apply any Orientation tags it finds in the EXIF.
libvips has a lower-level API based on GObject which is much easier to bind to. There's some discussion and example code in this issue, where someone is making a C# binding using p/invoke.
https://github.com/jcupitt/libvips/issues/558
The code for the C++ and PHP bindings might be a useful reference:
https://github.com/jcupitt/libvips/tree/master/cplusplus
https://github.com/jcupitt/php-vips-ext
That's a PHP binding for the entire library in 1800 lines of C.
I'd be very happy to help if I can. Open an issue on the libvips tracker:
https://github.com/jcupitt/libvips/issues
I'm basically reading several fields in an OpenCV FileNode, doing some calculations, and then replacing just one of the fields in the original OpenCV FileNode with the calculated data.
I can't find any methods that allow me to do this. Has anyone done this before?
Thanks for your help!
After some searching, it appears that I cannot append or add to an existing filenode or filestorage object.
However, what you can do is create a new FileStorage object, copy over any existing FileNodes you may want to keep, discard any old fields you do not want, and then save this new FileStorage object with the updated data.
I couldn't find a way to use the latest C++ interface to copy FileNodes, however, I did find a way to use the old deprecated structures to accomplish this. The following will copy mapped FileNode to a new FileStorage object.
cv::FileStorage fileStructure;
fileStructure.open("yourfile.xml", cv::FileStorage::WRITE);
CvFileStorage* fsPtr= fileStructure.operator *(); //gets the underlying pointer
cvWriteFileNode(fsPtr, "CopiedNode", fileNodeObject.operator *(),0);
I hope this helps people who are stuck like I was.
Best,
Paul
In OpenCV 4.0, there is a member function of FileNode
void setValue (int type, const void *value, int len=-1);
I haven't try, but it seems to design for this.
There seems not to be any official way to do this prior OpenCV 4.x. A workaround is to use the underlying basic element:
//type int with value of 5
cv::FileNode node;
CvFileNode* rawNode = *node;
//now the new value is 6
rawNode->data.i = 6;
In Module.php I have a some code (simplified version):
namespace Application;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
class Module{
public $somevariable = 'test';
public function onBootstrap( MvcEvent $e ) {
$this->somevariable = 'test2';
}
public function getValue(){
return $this->somevariable;
}
}
Next, I want to get value from variable "somevariable" in template layout.phtml. I do this as follows:
echo Application\Module::getValue();
but this doesn't work. What is wrong with that?
P.S. I never programmed much in PHP, so maybe I missed something :-(
you can use
$e->getViewModel()->setVariable('somevariable', 'somethingvalue');
and in the view :
echo $this->layout()->somevariable;
for detail, see this article : http://samsonasik.wordpress.com/2012/07/27/zend-framework-2-mvcevent-layout-view-get-namespace/
If a variable is just a string it doesn't make much sense to go with that approach. And please don't take this offensively, but if you don't have much experience in PHP (you tried to call a static function that is not static), then i wonder why you would start learning PHP with such a high class framework.
And if still you insist on doing that, please follow the official Documentation and read yourself through the whole QuickStart again and again. Check out some of the Modules out there and see how they do stuff.
Try to do the easy stuff first until you hit those points where you really need such functionality.
I'm calling the function window.navigator.geolocation.getCurrentPosition from Dart code. The final parameter to this function is optional. In JavaScript I would set the optional parameters as follows:
var wpid = navigator.geolocation.watchPosition(geo_success, geo_error,
{enableHighAccuracy:true, maximumAge:30000, timeout:27000});
What would the equivalent be in Dart code? I've tried the following but I'm not sure if it is correct:
window.navigator.geolocation.watchPosition(geo_success, geo_error,
{'enableHighAccuracy':true, 'maximumAge':30000, 'timeout':27000});
You are using this method: http://api.dartlang.org/docs/bleeding_edge/dart_html/Geolocation.html#watchPosition
int watchPosition(PositionCallback successCallback, [PositionErrorCallback errorCallback, Object options])
I do not have Dark SDK on this machine, but to me it looks completely fine. If the JavaScript equivalent code is just an object, then passing a Dart Map just like what you have done should be working. Is there a problem with it?
Hopefully passing a Map works, please try and let us know.
Even if it does work, this is a bad Dart API. The options really should be optional parameters, not properties of an options object. I filed a bug here: http://dartbug.com/6280
I had a problem on this matter, I'm using Eclipse with JDK 6.0
How can I resolve this problem:
Here's my code
public void processLevel(){
OBJ tempObjects;
if(mygfx.getBackPos() % 25 == 0){
tempObjects = new EnemyDrone(rndGenerator.nextInt() % Graphics.getScreenWidth(), 0 );
tempObjects.setY(tempObjects.getY() - tempObjects.getmybitmap().getHeight() + 3);
gameObjects.addElement(tempObjects);
}
}
the error says that "The method getScreenWidth() from the type Graphics is deprecated"
Thanks in advance guys.!!
Well, you should still be able to compile it with that code; deprecation is just a warning that the current way of doing something isn't the recommended way of doing it, and that there is a newer method that might have additional functionality or is better supported. In this case, you want to use Display.getWidth() to get the current width of the screen.
In general the documentation will say what method a deprecated method has been replaced with. For example, if you check out the documentation for the Graphics class in BB 6.0, it will say to use the static getWidth method of the Display class instead.
You should now use getWidth() of Display in net.rim.device.api.system.Display. The Deprecated API page is also useful.