This depends on the object you want to detect, 40 pictures might not nearly be enough. Cascade object detector can only detect objects to a certain angle and the width to heigth ratio shouldnt vary so much. For good results with the object detector you should consider a lot more positive and a even more negative images. And even then it depends on the object you want to detect, if the object is only a few pixels you wont have a good chance to get it to work.
If you can attach a example picture and the object you want to detect it would be easier to see, if it can be done.
EDIT: Since you now have a picture attached: The cascade object detector is meant to detect objects which doesnt vary much in ratio. Since the objects you want to detect have a variable ratio you will have a hard time to do so. Also there are not many significant points which could different the objects, so to get a reliable detector you would need a lot of positives and negatives, and even then you could get false detections. (by a lot i mean like 5000 positiv and 30000 or more negatives).
If you change the detection feature you might get better results.