It is well understood that data-acquisition by distributed sensors and subsequent transmission of all the acquired data to the cloud will produce a “data deluge” in next-generation wireless networks leading to immense network congestion, and data back-logs on the server which will prevent real-time processing and control. This motivates in situ data analytics in energy-constrained wireless sensor nodes that can perform context-aware acquisition and processing of data; and transmit data only when required. This paper presents a camera-based wireless sensor node with a self-optimizing end-to-end computation and communication design, targeted for surveillance applications. We demonstrate support for multiple feature-extraction and classification algorithms, tunable processing depth and power amplifier gain. Depending on the amount of information content, accuracy targets and condition of the wireless channel, the system choses the minimum-energy operating-point by dynamically optimizing the amount of processing done on the sensor itself. We demonstrate a complete system with ADI ADSP-BF707 image processor, OV7670 camera sensor, and USRP B200 software defined radio; and achieve $4.3\times $ reduction in energy consumption compared with a baseline design.