The Hough transform may be helpful to you in identifying curves. If you only need to count, it should work just fine. It can be generalized to detect any geometric shape that can be described using parameters, or any shape whatsoever using template matching. However, that can be expensive.
For sharp corners, you can use Harris corner detection as mentioned by @Diego in the above comment.
Definitely also check out jfeaturelib, it's helpful in extracting features from images (although if you just want to count/detect them it might be a little heavy-duty for your purposes).
Below are some implementations that may help you on your way:
- Hough transform in java
- Hough transform in javascript
- Harris corner detection in java
- Harris corner detection in javascript
You also might want to check out ImageJ by the NIH, there are quite a few Java plugins that may be helpful to you. It's used by many biologists (like me!) to detect image features and has hundreds of plugins for almost any conceivable purpose.