I remember an android app years ago that would simply use the proximity sensor to count push-ups. I think you could put it on your abdomen and count sit ups too using the accelerometer/gyroscope.
I have seen people with tripods in the gym. Filming the exercise and doing video analysis is probably the way to go - for example it can track bench press, like the other comment mentioned. The author here mentions that there are "plenty of apps on the App Store" that do that. But the tripod itself is an investment that I am not sure everyone will make.