There are alkaloids in the entire plant. However, these alkaloids are most concentrated in the ripe opium poppy pod. So sure, you might get something from an unripe pod, but you'll get the most opium latex if you are just patient and wait for your pod to swell up and get ripe.
It's similar to...