42
419 657 1038 642 610 566 526 574 534 672 571 667 563 476 562 620 616 638 548 637 584 560 475 617 564 584 1019 567 613 565 569 469 665 578 651 597 431 683 558 512 613 445 473 547 571 630 657 443 657 1046 537 546 668 554 708 693 655 465 623 559 593 511 1063 504 523 664 680 625 573 563 567 691 614 645 799 653 578 512 564 618 567 491 560 535 618 518 655 567 555 447 420 419 614 696 566 694 418 640 514 507 655 423 482 657 648 567 69 415 598 529 557 605 469 508 1041 651 470 721 450 561 554 525 774 654 510 423 599 661 418 587 650 491 530 570 628 622 663 578 546 558 651 555 610 656 488 657 434 595 685 1067 775 556 472 510 395 563 416 494 1040 504 632 601 569 625 476 488 683 530 550 432 418 614 403 419 572 547 515 635 415 640 658 551 696 513 547 540 567 682 487 517 529 1076 462 434 409 416 Lecture 6.3 Stereo processing Trym Vegard Haavardsholm

Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

419

657

1038

642

610

566

526

574

534

672

571

667

563

476

562

620

616

638

548

637

584 560

475

617

564

584

1019

567

613

565 569

469

665

578

651

597

431

683

558

512

613

445

473

547

571

630

657

443

657

1046

537

546

668

554

708 693

655

465

623

559

593

511

1063

504

523

664

680

625

573 563

567

691

614

645

799

653

578

512

564

618

567

491

560

535

618

518

655

567

555

447

420 419

614

696

566

694

418

640

514

507

655

423

482

657

648

567

69

415

598

529

557

605

469

508

1041 651

470

721

450

561

554

525

774

654

510

423

599

661

418

587 650

491

530

570

628

622

663

578 546

558

651

555

610 656

488

657

434

595

685

1067

775

556

472

510

395

563

416

494

1040

504

632

601

569

625

476 488

683

530

550

432 418

614

403

419

572 547

515

635

415

640

658

551

696

513

547

540 567

682

487 517

529

1076

462

434

409

416

Lecture 6.3 Stereo processing

Trym Vegard Haavardsholm

Page 2: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Stereo geometry

• Parallel identical cameras – Translated along x-axis

2

𝑥𝐿 𝑦𝐿

𝑧𝐿

𝑏𝑥

𝑷𝐿 = 𝑋,𝑌,𝑍

Page 3: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Stereo geometry

• Parallel identical cameras – Translated along x-axis

• Horizontal epipolar lines

– Corresponding points lie along the same row in the two images

3

𝑥𝐿 𝑦𝐿

𝑧𝐿

𝑏𝑥

𝑷𝐿 = 𝑋,𝑌,𝑍

Page 4: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Stereo geometry

• Parallel identical cameras – Translated along x-axis

• Horizontal epipolar lines

– Corresponding points lie along the same row in the two images

• Depth from disparity

4

𝑥𝐿 𝑦𝐿

𝑧𝐿

𝑏𝑥

𝑷𝐿 = 𝑋,𝑌,𝑍 𝑏𝑥

𝑍

𝑑

Page 5: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Stereo geometry

• Parallel identical cameras – Translated along x-axis

• Horizontal epipolar lines

– Corresponding points lie along the same row in the two images

• 3D from disparity

5

𝑥𝐿 𝑦𝐿

𝑧𝐿

𝑏𝑥

𝑷𝐿 = 𝑋,𝑌,𝑍 𝑏𝑥

𝑍

𝑑

xL

bX xd

= xL

bY yd

=

Page 6: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Stereo processing

• Sparse stereo – Extract keypoints – Match keypoints along the same row – Compute 3D from disparity

6

Page 7: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Sparse stereo matching

7

Example • Putative matches

Page 8: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Sparse stereo matching

8

Example • Matches consistent with epipolar line

• Length of yellow lines

corresponds to disparity

Page 9: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Sparse stereo matching

9

419

657

1038

642

610

566

526

574

534

672

571

667

563

476

562

620

616

638

548

637

584 560

475

617

564

584

1019

567

613

565 569

469

665

578

651

597

431

683

558

512

613

445

473

547

571

630

657

443

657

1046

537

546

668

554

708 693

655

465

623

559

593

511

1063

504

523

664

680

625

573 563

567

691

614

645

799

653

578

512

564

618

567

491

560

535

618

518

655

567

555

447

420 419

614

696

566

694

418

640

514

507

655

423

482

657

648

567

69

415

598

529

557

605

469

508

1041 651

470

721

450

561

554

525

774

654

510

423

599

661

418

587 650

491

530

570

628

622

663

578 546

558

651

555

610 656

488

657

434

595

685

1067

775

556

472

510

395

563

416

494

1040

504

632

601

569

625

476 488

683

530

550

432 418

614

403

419

572 547

515

635

415

640

658

551

696

513

547

540 567

682

487 517

529

1076

462

434

409

416

Example • Depth in meters for each matched point

• Computed directly from disparity

Page 10: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Sparse stereo matching

10

Example • Sparse 3D point cloud

• Each point has two descriptors

– Map for pose estimation with PnP!

Page 11: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Stereo processing

• Sparse stereo – Extract keypoints – Match keypoints along the same row – Compute 3D from disparity

• Dense stereo – Try to match all pixels along rows – Compute disparity image by finding the best disparity for each pixel – Refine and clean disparity image – Compute dense 3D point cloud or surface from disparity

11

419

657

1038

642

610

566

526

574

534

672

571

667

563

476

562

620

616

638

548

637

584 560

475

617

564

584

1019

567

613

565 569

469

665

578

651

597

431

683

558

512

613

445

473

547

571

630

657

443

657

1046

537

546

668

554

708 693

655

465

623

559

593

511

1063

504

523

664

680

625

573 563

567

691

614

645

799

653

578

512

564

618

567

491

560

535

618

518

655

567

555

447

420 419

614

696

566

694

418

640

514

507

655

423

482

657

648

567

69

415

598

529

557

605

469

508

1041 651

470

721

450

561

554

525

774

654

510

423

599

661

418

587 650

491

530

570

628

622

663

578 546

558

651

555

610 656

488

657

434

595

685

1067

775

556

472

510

395

563

416

494

1040

504

632

601

569

625

476 488

683

530

550

432 418

614

403

419

572 547

515

635

415

640

658

551

696

513

547

540 567

682

487 517

529

1076

462

434

409

416

Page 12: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Dense stereo matching

12

• For a patch in the left image – Compare with patches along

the same row in the right image

Page 13: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

-300-200-1000100200300

Disparity (pixels)

-0.5

0

0.5

Sim

ilarit

y

Dense stereo matching

13

• For a patch in the left image – Compare with patches along

the same row in the right image

Page 14: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

-300-200-1000100200300

Disparity (pixels)

-0.5

0

0.5

Sim

ilarit

y

Dense stereo matching

14

• For a patch in the left image – Compare with patches along

the same row in the right image – Select patch with highest score

Page 15: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

-300-200-1000100200300

Disparity (pixels)

-0.5

0

0.5

Sim

ilarit

y

Dense stereo matching

15

• For a patch in the left image – Compare with patches along

the same row in the right image – Select patch with highest score

• Repeat for all pixels in the left image

Page 16: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

-300-200-1000100200300

Disparity (pixels)

-0.5

0

0.5

Sim

ilarit

y

Dense stereo matching

16

• Computational cost – 𝑂(𝐷𝑊2𝑁2)

𝑊

𝑁

Page 17: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Dense stereo matching

17

• Size of window – Small: More difficult to match, noisy

𝑊

Page 18: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Dense stereo matching

18

• Size of window – Small: More difficult to match, noisy – Large: Loss of detail, smooth, slow

𝑊

Page 19: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

-300-200-1000100200300

Disparity (pixels)

-0.5

0

0.5

Sim

ilarit

y

Dense stereo matching

19

• Restrict disparity range – Less computation – Less memory – Less matching errors

Page 20: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

-300-200-1000100200300

Disparity (pixels)

-0.5

0

0.5

Sim

ilarit

y

Dense stereo matching

20

• Restrict disparity range – Less computation – Less memory – Less matching errors

Page 21: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Disparity Space Image (DSI)

21

• The element 𝐷(𝑢, 𝑣,𝑑) is the similarity between the support regions centered at (𝑢𝐿, 𝑣𝐿) in the left image and (𝑢𝐿 − 𝑑, 𝑣𝐿) in the right image

Page 22: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Disparity Space Image (DSI)

22

• The element 𝐷(𝑢, 𝑣,𝑑) is the similarity between the support regions centered at (𝑢𝐿, 𝑣𝐿) in the left image and (𝑢𝐿 − 𝑑, 𝑣𝐿) in the right image

Page 23: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Stereo matching failures

23

• Single strong unambiguous peak

10 20 30 40 50 60 70

Disparity (pixels)

-0.2

0

0.2

0.4

0.6

0.8

Sim

ilarit

y

Page 24: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

10 20 30 40 50 60 70

Disparity (pixels)

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

Sim

ilarit

y

Stereo matching failures

24

• Several ambiguous peaks – Which is the correct peak? – Repeating patterns – Detect with ratio test

Page 25: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

10 20 30 40 50 60 70

Disparity (pixels)

-0.2

-0.1

0

0.1

0.2

0.3

0.4

0.5

Sim

ilarit

y

Stereo matching failures

25

• A weak peak – Often occlusion, parallax

Page 26: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

10 20 30 40 50 60 70

Disparity (pixels)

-0.2

-0.1

0

0.1

0.2

0.3

0.4

0.5

Sim

ilarit

y

Stereo matching failures

26

• A weak peak – Often occlusion, parallax

Page 27: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

10 20 30 40 50 60 70

Disparity (pixels)

-0.2

-0.1

0

0.1

0.2

0.3

0.4

0.5

Sim

ilarit

y

Stereo matching failures

27

• A weak peak – Often occlusion, parallax

Page 28: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

10 20 30 40 50 60 70

Disparity (pixels)

-0.2

-0.1

0

0.1

0.2

0.3

0.4

0.5

Sim

ilarit

y

Stereo matching failures

28

• A weak peak – Often occlusion, parallax – Worse with larger baseline – Detect by thresholding similarity score

Page 29: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Stereo matching failures

29

• A weak peak – Often occlusion, parallax – Worse with larger baseline – Detect by thresholding similarity score

Page 30: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

10 20 30 40 50 60 70

Disparity (pixels)

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

Sim

ilarit

y

Stereo matching failures

30

• A broad peak – Little texture – Detect with texture metrics or

from peak estimates

Page 31: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Determining position of peaks

31

• Fit a parabola to the peak and its neighbors – 𝑠 = 𝐴𝑑2 + 𝐵𝑑 + 𝐶

– �̂� = −𝐵2𝐴

• Avoids steps in depth

10 20 30 40 50 60 70

Disparity (pixels)

-0.2

0

0.2

0.4

0.6

0.8

Sim

ilarit

y

Page 32: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Dense stereo example

32

Page 33: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Dense stereo example

33

• Raw disparity image

Page 34: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Dense stereo example

34

• Detection of failures – Blue: Ok – Red: Outside image – Orange: Broad peaks – Green: Low similarity

• In computer vision in general:

– Smooth and fill holes

• In robotics: – Typically better to remove

uncertain points

Page 35: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Dense stereo example

35

• Disparity image – Failures removed

Page 36: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Dense stereo example

36

• Dense 3D point cloud

Page 37: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Smooth stereo: Global optimization

37

• Instead of finding best disparity for each pixel, find 𝑑 so that global energy is minimum:

𝐸 𝑑 = 𝐸𝑑 𝑑 + 𝜆𝐸𝑠(𝑑)

Page 38: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Semi Global Matching example

38

• SGBM Heiko Hirschmuller, “Stereo processing by semiglobal matching and mutual information”. Pattern Analysis and Machine Intelligence, IEEE Transactions on, 30(2):328–341, 2008

Page 39: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Semi Global Matching example

39

• SGBM Heiko Hirschmuller, “Stereo processing by semiglobal matching and mutual information”. Pattern Analysis and Machine Intelligence, IEEE Transactions on, 30(2):328–341, 2008

• Disparity image

Page 40: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Semi Global Matching example

40

• SGBM Heiko Hirschmuller, “Stereo processing by semiglobal matching and mutual information”. Pattern Analysis and Machine Intelligence, IEEE Transactions on, 30(2):328–341, 2008

• 3D point cloud

Page 41: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Semi Global Matching example

41

• SGBM Heiko Hirschmuller, “Stereo processing by semiglobal matching and mutual information”. Pattern Analysis and Machine Intelligence, IEEE Transactions on, 30(2):328–341, 2008

• Textured surface

Page 42: Lecture 6.3 Stereo processing · Stereo geometry • Parallel identical cameras – Translated along . x-axis • Horizontal epipolar lines – Corresponding points lie along the

Summary

• Stereo imaging – Horizontal epipolar lines – Disparity – 3D from disparity – Stereo rectification

• Stereo processing

– Sparse vs dense matching – DSI – Typical failures – Removing failures vs smoothness

• Additional reading – Szeliski: 11.2-11.5 – http://vision.middlebury.edu/stereo/

• Matlab toolkit:

– Peter Corke’s Robotics Toolbox and Machine Vision Toolbox http://www.petercorke.com/Toolboxes.html

• Lab:

– Make your own stereo camera!

42