dear friends, i use openCV in Java. Everything is fine but the thing is that am limited with API, i cant create C files (i'm not skilled in C/C++ that much and i did not use them for a long time) for my specific tasks, thus i must solve my problem with haar cascade xml file...
My task is to detect simple objects NOT FACEs, just simple objects like cup on the table, clock on the wall...
I think it is possible with edge detecting, but i did not find any cascades for this simple detection stuff. It is quite hard for me to google it because when i search object detection it always gives face detection stuff...
Could you please suggest me solution for this?
Your help will be appreciated.
Regards.
You can create your own haarcascades, but it's a lot of work!
You will find some interesting links in the answers to this question.
As you said, there are other ways to detect objects, like edge detection or color tracking for instance. There are plenty of resources for this on the web.
I guess i find the solution,
1) Solution one - there is very useful blob function witch does exactly what i wanted to, and even more, it detects center of the blob...
2) You can use deprecated method CV.findContours(...) and do your necessary stuff.
Please let me know if you have any suggestions or fixes to this...
Related
I'm currently working on a training plugin, where every player would get his own region, to learn bridge for example. So when a player joins, the plugin should automatically generate a new area for this player and delete it when he leaves.
I've created a SetupCommand where you have to set the start and end of the region that should be copied.
Now the only thing to do is copy the region and teleport the player to it, however, I couldn't find any good ways to do that. The only solution I found so far is to loop through all blocks and copy them one by one. But I can imagine that this is not the best solution and would cause lag, not only server-side but also client-side.
Are there better ways to clone a region than that?
I've read you should use Schematics but they weren't going into detail.
If you are experienced with java and feel comfortable about your skills you can try to get the blocks in the list as List and save it as base64 into your database or whatelse. You can parse it everytime back into a list of blocks and replace it. I would rather recommend you to make a custom block class with implements Serializeable and then add some values like Location, Material and BlockData to it.
Use FAWE or WorldEdit to copy/paste sections
If you use Block#setType, performance will be very slow, so if you don't want to use the API, you should use NMS, but using NMS is not a good practice.
Disadvantages of NMS:
Most nms methods are obfuscated. In one version the method is called f(), in the next version maybe c().
How to copy/paste with FAWE:
https://www.spigotmc.org/threads/how-to-paste-a-schematic-with-fawe.402950/
How to copy/paste with worldedit:
https://www.spigotmc.org/threads/worldedit-api-schematic-copy-save-load-and-paste.498476/
In conclusion, it is recommended to use the API
I use GraphViz to draw oriented graph - I read file with graph data according to http://graphstream-project.org/doc/Tutorials/Reading-files-using-FileSource/ tutorial.
Everything works fine when there is not two or more edges between two nodes. If so, the org.graphstream.graph.IdAlreadyInUseException: singleton exception: id "(48;63)" already in use. Cannot create an edge. is thrown.
I understand the exeption quite well. The problem is that I don't know how to get rid of it (and I don't want to write my own data parser).
Does anyone know how to solve this?
I don't know about graphviz, but the error you get and the tutorial you refer to are GraphStream related.
In GraphStream, you need to use the MultiGraph class in place of the DefaultGraph one.
Yesterday I made this question: Java function on function
For help and get marked as Duplicate but I think I didn't get understand there what I want and now I try again.
I want methods can be only called on methods for example we have the class Roads and on the road we will go a Way.
Roads.Way1()
After we choose the Way1 we will go to Path1
Roads.Way1().Path1()
But if we choose Way2
Roads.Way2()
We are not able to go to Path1() cause Way2() goes to Garden1() so
Roads.Way2().Garden1()
So what I try to say you can only use the methods(functions) in a wanted way and I saw this on different API or Library. So for the good understanding
Way1 goes to Path1 and ISN't able to go to Garden1
Way2 goes to Garden1 and ISN't able to go to Path1
So how to manager that I can make different roads that has there own ways so I could make like
Roads.Way1().
/*
Goes to:
Path1()
Fountain()
Market()
*/
And Way to cant access them and can only use there own destinations.
I think what you are asking for is: how can I express "control flow" using "language features". And well, there would be ways to get there: you would need a lot of different classes (or maybe interfaces); so something that is a "Way2" would simply not offer a "Path1" method.
But: doing so sounds like bad idea. It will work fine initially, but as soon as you start extending your system, you will be running into problems all the time:
"Hmm, I need to change Way2; it should now allow to go Path1; but uups; there are some Way2-thingies that should not allow Path1; so I actually need a Way3-thingy" and so on. Chances are extremely high that maintaining this code will turn into a nightmare very soon.
I know, this is just an opinion, but my gut feeling is: you are looking for the wrong solution to your problem. Instead, you should spent time on identifying what your actual problem is; and then think about better ways to solve that problem!
I was wondering if anyone could please point me the right direction on how to approach the scheduling problem.
I have a teacher/student timetable problem, where I have teachers that teach certain subject at certain times and students that have preferences as of which class they want to take an when. The goal is to create a timetable not necessarily optimal solution.
I looked around here and there is a great number of discussions here on this website on this topic and the ones that I found go from super general to excessively difficult and I am currently unable to understand which programming/logic concepts to use to at least conceptualize the program work-flow.
Could anyone that dealt with similar problems explain how these types of problems are dealt with. I do not need the code (although pseudo-code would be awesome), but some guidelines ie step#1 - do this, step#2 - do that, step#3 - do etc....
Also, are there any libraries that are available that can do scheduling with preferences effectively and that have fairly straightforward inputs?
Many thanks!!
here is the outline of a problem that I have.
Let's say I have a group of salespeople:
The goal is to create a schedule that pairs buyer and seller subject to time availability and preferences.
This is a course time-tabling problem, right?
Can I accomplish with Drool Planner?
Take a look at the curriculum course scheduling problem which schedules lectures of teacher and students into timeslots and rooms. Take a look at my open source implementation in Java or just download and run the example.
I 've configured the construction heuristic First Fit Decreasing with the metaheuristic Tabu Search. I tried other configurations too, see my benchmarker config.
First you should make a list of resources for your problem. Then you should write down the constraints and set up a mathematical model. Finally you can use some optimization tool to generate solutions.
Of course this is not as easy as it seems to be. This page may give you some insight about possible solutions.
Matlab has a Global Optimization toolbox which lets you do genetic algorithm optimization with a very simple, point-and-click GUI that has helpful documentation. From what wikipedia says, your problem is just the kind to solve with a GA.
If you don't have access to the toolbox, you should be able to find genetic algorithm libraries for java, or worst comes to worst you can write your own. It won't be as extensive and it will take some work, but it shouldn't be terribly hard to make a simple one.
I'm having a bit of trouble figuring this out so if you can help that would be great.
I have written a bit of code that gets a list of URLs from a sitemap. I then go each page, scrape all the links, and then test their status(200,404, etc).
I am using HttpClient. I have it all working OK but as I am new to Java I reckon my code is a complete hack/maze and I could most likely get far better performance if it was organised correctly. So what I have is
Main class - This builds the gui
Parse the sitemap class - This parses the sitemap and get a list of the urls.
Class called PingURl - I'm sure my above is poor but this is the bit I reckon is worst. This class opens all the urls, scrapes them for links, then tests the links for their status and returns it. I presume this class should be broken down? Most importantly I think I should be isolating the testing of the links in it's own class, so it would be easy to implement threads later on?
Basically I'm looking for advice. If someone could help me with laying out the project a bit better. Secondly I believe this is my weakest area so to improve I need to learn more about this, I don't even know what to call this(design/layout problem?). Can you also recommend resources to learn more about this?
Java is a language which IMO, embodies good OO design. Designing with OO in mind is very effective.
http://java.sun.com/developer/onlineTraining/Programming/BasicJava2/oo.html
In terms of your problem, I think it works pretty well. You are kind of following a Model-View-Controller pattern: http://www.codinghorror.com/blog/2008/05/understanding-model-view-controller.html
I can't tell you how to design your code, but I will tell you how I would do it if I were presented with the same problem:
I would get a class to represent a hyperlink. In that class there would be the hyperlink that has been scraped, and a getter and setter. As well as a boolean value and a ping function. That means that if I create a "hyperlink" object, then I can invoke ("ping") on that object because it is part of that class. That means that the ping function simply sets the boolean that represents connectivity.
That way, your parser basically gets a page, and for each link it finds, it creates a new "hyperlink" object based on your own "hyperlink" class. And puts it in an array. So once your parser executes you get an array of pointers to hyperlinks.
Then all you have to do is invoke the ping function on each one to see if it is there.
I think this design is the best because it scales from doing one hyperlink test to doing 1000 quite easily.
There is soooo much stuff out there about design, there are countless principals as well. There is never one absolute way to solve a problem. But the more experience you get, and the more you read up on design patterns and models the better you will get at it :)