You can use the indexer to get all the accounts that opted in an application:
However note that accounts may clear out their state.
If when clearing out, their vote is removed, then the above still works.
If when clearing out, their vote should still be counted, then you need to use another approach such as looking at all the transactions involving the voting app application call using indexer - Algorand Developer Portal