Resource-Constrained Learning and Inference for Visual Perception