CodingTrain / CodingTrain/Suggestion-Box

Realtime Panorama using a webcam

Aperta
#439 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Nessun dato sulla lingua
Stelle
570
Fork
85
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

My suggestion is to make a tutorial showing how to make a realtime panorama with a camera.
Searching on web, a few people have done it but they not show the code .
I tried to make it, but without success ='(

```
import boofcv.processing.*;
import boofcv.struct.image.*;
import boofcv.struct.feature.*;
import georegression.struct.point.*;
import java.util.*;
import processing.video.*;

Capture video;

PImage prevFrame;
PImage current;

int leu = 0;
int c = 1;
float avgX = 0;
float avgY = 0;

List locations0, locations1; // feature locations
List matches; // which features are matched together

void setup() {

size(600, 240);
video = new Capture(this, 320, 240, 30);
video.start();

prevFrame = createImage(video.width, video.height, RGB);
current = createImage(video.width, video.height, RGB);
}
void detectar() {
SimpleDetectDescribePoint ddp = Boof.detectSurf(true, ImageDataType.F32); //usar SURF
SimpleAssociateDescription assoc = Boof.associateGreedy(ddp, true); // busca interminavel

// Find the features
ddp.process(prevFrame);
locations0 = ddp.getLocations();
List descs0 = ddp.getDescriptions();

ddp.process(current);
locations1 = ddp.getLocations();
List descs1 = ddp.getDescriptions();

// associar os pontos
assoc.associate(descs0, descs1);
matches = assoc.getMatches();
}

void draw() {

loadPixels();
video.loadPixels();
prevFrame.loadPixels();

detectar();
int count = 0;
for ( AssociatedIndex i : matches ) {
if ( count++ % 20 != 0 )
continue;
else if ( count > 100)
{
break;
}

Point2D_F64 p0 = locations0.get(i.src);
Point2D_F64 p1 = locations1.get(i.dst);
float diferencaX = abs((float) p0.x - (float)p1.x);
float diferencaY = abs((float) p0.y - (float)p1.y);

if (leu < 30) {

if (diferencaY < 15) {
avgX = avgX + (diferencaX - avgX)/c;
avgY = avgY + (diferencaY - avgY)/c;
c++;
println(c);
}
}

if ( leu == 29) {
println("oi");
if (avgX > 300) {
translacao();
}
}
leu++;
}
}

void translacao() {
image( prevFrame, 0, 0 );
image( current, avgX, -avgY);
updatePixels();
println(avgX);
c = leu = 0;
avgX = avgY = 0;
}

void captureEvent(Capture video) {
// Save previous frame for motion detection!!
// Before we read the new frame, we always save the previous frame for comparison!
if (avgX > 300) {
prevFrame.copy(video, 0, 0, video.width, video.height, 0, 0, video.width, video.height);
prevFrame.updatePixels(); // Read image from the camera
}
video.read();
current.copy(video, 0, 0, video.width, video.height, 0, 0, video.width, video.height);
current.updatePixels();
}

```

Here are some examples:

https://www.youtube.com/watch?v=QapSxGnUWtY&t
https://www.youtube.com/watch?v=434zw201iN8
https://www.youtube.com/watch?v=rXcupvutRMs

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.