calculating the likelihood for detected legs