Fix patch jacobians
This commit is contained in:
parent
2af4a6fa3d
commit
c45ee335dc
|
@ -105,10 +105,12 @@ struct OpticalFlowPatch {
|
||||||
|
|
||||||
for (int i = 0; i < PATTERN_SIZE; i++) {
|
for (int i = 0; i < PATTERN_SIZE; i++) {
|
||||||
if (data[i] >= 0) {
|
if (data[i] >= 0) {
|
||||||
|
const Scalar data_i = data[i];
|
||||||
|
const Vector2 grad_i = grad.row(i);
|
||||||
|
grad.row(i) =
|
||||||
|
num_valid_points * (grad_i * sum - grad_sum * data_i) / (sum * sum);
|
||||||
|
|
||||||
data[i] *= mean_inv;
|
data[i] *= mean_inv;
|
||||||
Vector2 grad_i = grad.row(i);
|
|
||||||
grad.row(i) = num_valid_points * (grad_i * sum - grad_sum * data[i]) /
|
|
||||||
(sum * sum);
|
|
||||||
} else {
|
} else {
|
||||||
grad.row(i).setZero();
|
grad.row(i).setZero();
|
||||||
}
|
}
|
||||||
|
@ -148,7 +150,7 @@ struct OpticalFlowPatch {
|
||||||
|
|
||||||
for (int i = 0; i < PATTERN_SIZE; i++) {
|
for (int i = 0; i < PATTERN_SIZE; i++) {
|
||||||
if (residual[i] >= 0 && data[i] >= 0) {
|
if (residual[i] >= 0 && data[i] >= 0) {
|
||||||
Scalar val = residual[i];
|
const Scalar val = residual[i];
|
||||||
residual[i] = num_valid_points * val / sum - data[i];
|
residual[i] = num_valid_points * val / sum - data[i];
|
||||||
num_residuals++;
|
num_residuals++;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue