Basically it is normal that adding more functionality, and thus requiring more computational time, will increase the time between each framegrab and thus reduce the FPS.
I suggest trying the following:
- Start by compiling in release and not in debug. It removes tons of overhead and unneccesary checks once you know the function is working correctly.
- Try using GPU enabled counterparts of the functions. You will need to build openCV with CUDA or OpenCL support for that, but it works expecially well for larger images due to block processing.
- You are limiting your capture speed to 30 FPS, which I think is pretty low for an industrial cam.Most of them go easily to 60 FPS. Make sure it is enabled at the highest speed possible.
- Just don't expect that a combo of object tracking and detection will run at like 30 FPS. We have complete PhD studies about these problems, which all reach about 25FPS with tons of optimalisations.
- Last but not least, if you have a multicore system, this might be the good time to consider using threads and pushing threads to different cores to reduce the calculation time. However this is a step further and does require a good knowledge on parallelization.