nxt cam LineTracking TOPIC

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

smart_app123
New User
Posts: 18
Joined: Thu Jan 11, 2018 11:35 am

nxt cam LineTracking TOPIC

Postby smart_app123 » Thu Feb 01, 2018 9:18 am

I try to do a light racing activity using nxt Cam V5, if you find a line, go straight along that line and make a left turn if you do not see it,
However, several lines are detected, not lines, but lines are detected as non-lines.
And I do not know how the scope of nxt cam is implemented.

I simply tried coding.

import lejos.hardware.Button;
import lejos.hardware.Sound;
import lejos.hardware.motor.Motor;
import lejos.hardware.port.SensorPort;
import lejos.hardware.sensor.EV3ColorSensor;
import lejos.utility.Delay;

public class nxtCamTest {
final static int INTERVAL = 1000;
final static NXTCamV5 Senser= new NXTCamV5(SensorPort.S2);
public static void main(String[] args) {
System.out.println("NXTCamV5 LINE_TRACKING");
Senser= .setTrackingMode(NXTCamV5.LINE_TRACKING);
while (!Button.ESCAPE.isDown()) {
int trackedObject = Senser= .getNumberOfObjects();
System.out.println(trackedObject);


if(Button.UP.isDown() == true)
{
Motor.A.setSpeed(100);
Motor.A.forward();
}

if(Button.DOWN.isDown() == true)
{
Motor.A.setSpeed(100);
Motor.A.backward();
}

if (trackedObject > 0)
{
Delay.msDelay(20);
Motor.B.setSpeed(180);
Motor.C.setSpeed(180);
Motor.B.forward();
Motor.C.forward();
//Delay.msDelay(500);
}
else
{
Delay.msDelay(20);
Motor.B.setSpeed(1);
Motor.C.setSpeed(100);
Delay.msDelay(500);
}

while (Button.ESCAPE.isDown()) { // exit
Senser.close(); //
System.exit(0);
}
Delay.msDelay(500);
}
}
}



*************
I want help, and can I ask another question? Is it red, moving along the line? Can you stop or advance when you find green?
I wonder,

User avatar
gloomyandy
leJOS Team Member
Posts: 6017
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: nxt cam LineTracking TOPIC

Postby gloomyandy » Thu Feb 01, 2018 3:56 pm

Sorry can't help as I've never tried to use the NXTCam in line tracking mode. What I can say is that the NXTCam is a very complex sensor to work with and is very sensitive to the lighting conditions that you are using it under (as are all low cost camera based sensors). It will not be an easy project to work with.

Oh and if you are posting code please use the code tags it makes it much easier to read.
leJOS news https://lejosnews.wordpress.com/

smart_app123
New User
Posts: 18
Joined: Thu Jan 11, 2018 11:35 am

Re: nxt cam LineTracking TOPIC

Postby smart_app123 » Thu Feb 01, 2018 11:59 pm

What does the code tag mean?

Well .. I want the same action as the YouTube video below.

https://youtu.be/0Z0MfPTkpmU

https://youtu.be/3uou9r59vzc

User avatar
gloomyandy
leJOS Team Member
Posts: 6017
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: nxt cam LineTracking TOPIC

Postby gloomyandy » Fri Feb 02, 2018 8:14 am

The code tags are used to surround code. When you are making a post look just above where you are typing you will see a line of buttons labelled..
"B" "i" "u" "Quote" "Code" etc.

These can be used to format your post. If you use the "Code" tag then your code will look like this...

Code: Select all

   private static int convertYUVtoARGB(int y, int u, int v) {
        int c = y - 16;
        int d = u - 128;
        int e = v - 128;
        int r = (298*c+409*e+128)/256;
        int g = (298*c-100*d-208*e+128)/256;
        int b = (298*c+516*d+128)/256;
        r = r>255? 255 : r<0 ? 0 : r;
        g = g>255? 255 : g<0 ? 0 : g;
        b = b>255? 255 : b<0 ? 0 : b;
        return 0xff000000 | (r<<16) | (g<<8) | b;
    }


Which is much easier to read.
leJOS news https://lejosnews.wordpress.com/

smart_app123
New User
Posts: 18
Joined: Thu Jan 11, 2018 11:35 am

Re: nxt cam LineTracking TOPIC

Postby smart_app123 » Mon Feb 05, 2018 12:38 am

I do not know what that function does.
What is int y, u, v?

User avatar
gloomyandy
leJOS Team Member
Posts: 6017
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: nxt cam LineTracking TOPIC

Postby gloomyandy » Mon Feb 05, 2018 9:25 am

Ignore the code it was just and example of how to use the code tags!
leJOS news https://lejosnews.wordpress.com/


Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 1 guest