So the biggest problem comes from the fact that in order to get a Comparator signal from a Storage or Hopper Minecart, the Minecart needs to be resting on detector rail.*
Obviously this is a problem, since you can't cause the Minecart to move using detector rail. For this you need a block swapper. The traditional ultra simple design doesn't seem to work anymore, so instead, you need to use some control circuitry. Luckily, I found a design on YouTube purpose built for block swappers:
You'll be swapping detector rail and powered rail in a horizontal fashion, like so:
Notice the redstone torch behind the centre piston. It isn't obvious from the video that it's required.
Next we need to work out the wiring to trigger the block swapper. I did this to your specs which were basically (in psuedocode)
if(!cart.empty() && hopper.empty())
This isn't really ideal, since the cart can be full even if there's items left in the hopper. You would need to add
|| cart.full() to the above
if statement to make it more useable.
Now, there's one more thing. You don't want to keep the Minecart racing back and forth after you send it off. In order to accomplish this, you need to trigger the block swapper a second time to replace the detector rail after the Minecart leaves. I accomplished this with a delay circuit like so:
Finally, during my testing, I discovered that Storage Minecarts don't seem to work. They aren't being filled by the hopper, and
I'm not sure why I'm guessing it's because there's a powered detector rail beneath it. Hopper Minecarts work just fine. Also, I've created an MCEdit schematic file that you can get here that contains the system shown in these images. It doesn't include the full cart detection logic either. Implementation of that is left to the reader.
*This was tested with the 1.8 snapshots. I don't know if this was always the behaviour, or was recently introduced.