Bogomolov–Gieseker‐type inequality and counting invariants