Overlaying static text but moving vertically

Store Forums Video Experimenter General Discussion Overlaying static text but moving vertically

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #9048
    zhengys18
    Participant

    I am trying to overlay the time on a fixed position on the video stream (0,0), however, the output of the video stream has the text but moving vertical along the same line all the time. Anybody encounter the same question?

    #9049
    Michael
    Keymaster

    Can you post your code so we can have a look?

    #9050
    zhengys18
    Participant

    #include <TVout.h>
    #include <fontALL.h>

    #define W 128
    #define H 72

    TVout tv;
    unsigned char x,y;
    unsigned char originx = 5;
    unsigned char originy = 80;
    unsigned char plotx = originx;
    unsigned char ploty = 40;
    char s[64];
    unsigned int n = 0;
    int index = 0;
    int messageLen = 32;
    char message[] = “…OVERLAY TEXT AND GRAPHICS ON A VIDEO SIGNAL…OVERLAY TEXT AND GRAPHICS ON A VIDEO SIGNAL”;
    char saveChar;
    float t=0;

    unsigned long time1;
    unsigned long time2;

    void setup() {
    tv.begin(NTSC, W, H);
    initOverlay();
    tv.select_font(font4x6);
    tv.fill(0);
    Serial.begin(9600);
    t=0;
    }
    // Initialize ATMega registers for video overlay capability.
    // Must be called after tv.begin().
    void initOverlay() {
    TCCR1A = 0;
    // Enable timer1. ICES0 is set to 0 for falling edge detection on input capture pin.
    TCCR1B = _BV(CS10);

    // Enable input capture interrupt
    TIMSK1 |= _BV(ICIE1);

    // Enable external interrupt INT0 on pin 2 with falling edge.
    EIMSK = _BV(INT0);
    EICRA = _BV(ISC01);
    }

    // Required to reset the scan line when the vertical sync occurs
    ISR(INT0_vect) {
    display.scanLine = 0;
    }

    void loop() {
    time1 = millis();
    tv.delay_frame(1);
    int int_t=int(t*1000);
    sprintf(s, “%d”,int_t);

    t=t+0.001;
    tv.fill(0);
    tv.print(0, 0, s);
    //tv.draw_line(-10,0,W,0,1);
    //tv.draw_line(-10,0,0,H,1);

    time2 = millis();
    delay(50-(time2-time1));
    }

    I also use the code here: http://nootropicdesign.com/projectlab/2011/03/20/text-and-graphics-overlay/
    but the number still is moving vertically.

    #9051
    Michael
    Keymaster

    Hmm, the timing is off. Did you buy an assembled Video Experimenter or a kit that you assembled?
    I’d check to make sure you have a good connection on digital pin 2. That is the vertical sync.
    Also, you might try another video source and another video display.

    #9052
    zhengys18
    Participant

    I buy the assembled one. I configured the digital pin 2 using the same Arduino before, will it cause any problem? If so, how can I reset to its original state?

    #9053
    zhengys18
    Participant

    Also, currently I only have 1 wire connected to the video input,1 wire to the gnd and use RCA video output. Do I need to connect anything to D2?

    #9054
    zhengys18
    Participant

    Ok. Problem solved. Previously I configured pin2 as output using pinmode. Seems like then the interrupt is detached. I reattached the interrupt and now it is working. Thanks a lot.

    A following question is that is there any way to put text on the corner of the video? I set it to (0,0) and it is not using the whole screen.

    #9055
    Michael
    Keymaster

    The viewport may not take up the entire screen on some screens. You can adjust the top edge by changing this value:

    display.output_delay = 130;

    Try values between 130 and 200 to see the difference.

    To change the left edge, change this value:

    display.start_render = 10;

    Try values between 10 and 70 to see how the left edge changes.
    This may help you move the entire viewport up to the upper left corner…

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.