Adding text to video

RVMedia support and discussion (components for displaying and controlling IP cameras, webcams, video conferencing, video chats, recording audio and video files)
Post Reply
kennyJeon
Posts: 4
Joined: Fri Jun 16, 2023 8:32 am

Adding text to video

Post by kennyJeon »

Hello

I am recording a web camera with text information using the OnGetImage event

When I used RVMediaVCLSetupVer8.exe, it was recorded well

But when I try to record using RVMediaVCLSetup_v11.exe

The web screen is overlapping with text on the screen when Camera On

What is wrong? Please advise

Thank you!
V11.png
V11.png (129.28 KiB) Viewed 4985 times
V8.png
V8.png (151.12 KiB) Viewed 4985 times
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Adding text to video

Post by Sergey Tkachenko »

What's your code for writing text?
Most probably, it should be protected by a critical section.
kennyJeon
Posts: 4
Joined: Fri Jun 16, 2023 8:32 am

Re: Adding text to video

Post by kennyJeon »

Code: Select all

procedure TfrmMain.RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);
var
  bmp: TBitmap;
  sDisplayStemp : Array[0..20] of String;
  iSZ: TSize;
  rDT, rTS : Real;
  iTH, iTM, iDY : Integer;
  i, iBtCnt : Integer;
  sTS : String;
begin
  rDT := Now;
  iDY := Trunc(rDT);
  rDT := rDT - iDY;

  iTH := Trunc(rDT * 24);
  iTM := Trunc(rDT * 24 * 60) - (iTH * 60);
  rTS := (rDT * 24 * 60 * 60) - (iTH * 60 * 60) - (iTM * 60);

  if rTS > 10 then sTS := Format('%2.1f', [rTS])
    else sTS := '0' + Format('%2.1f', [rTS]);

  bmp := img.GetBitmap;

  with bmp.Canvas do
  begin
    Lock;
    try
      if CFG.bBkView then
      begin
        Brush.Style := bsSolid;
        Brush.Color := CFG.iBkCR;

        Rectangle(cfg.iSX, cfg.iSY, CFG.iEX, CFG.iEY);
      end;

      Brush.Style := bsClear;
      Font.PixelsPerInch := 96;

      iBtCnt := 0;

      IND.sVal[0] := FormatDateTime('yyyy.mm.dd.', now);
      IND.sVal[1] := Format('%2d:%.2d:', [iTH, iTM]) + sTS;
      IND.sVal[2] := Format('%8.2f', [IND.rTM]);

      for i := 0 to 20 do
      begin
        if CFG.bView[i] then
        begin
          Font.Name  := CFG.sFtNm[i];// 'Tahoma';
          Font.Color := CFG.iFtCR[i]; // clWhite;
          Font.Size  := CFG.iFtSZ[i];  // 32

          if not CFG.bStyle[i, 0] and not CFG.bStyle[i, 1] then Font.Style := [];
          if not CFG.bStyle[i, 0] and     CFG.bStyle[i, 1] then Font.Style := [fsItalic];
          if     CFG.bStyle[i, 0] and not CFG.bStyle[i, 1] then Font.Style := [fsBold];
          if     CFG.bStyle[i, 0] and     CFG.bStyle[i, 1] then Font.Style := [fsBold,fsItalic];

          sDisplayStemp[i] := CFG.sTitle[i] + IND.sVal[i] + ' ' + CFG.sUnit[i];

          TextOut(CFG.iX[i], CFG.iY[i], sDisplayStemp[i]);
        end;
      end;

    finally
      Unlock;
    end;
  end;
  img.UpdateData;
end;
kennyJeon
Posts: 4
Joined: Fri Jun 16, 2023 8:32 am

Re: Adding text to video

Post by kennyJeon »

Written in Delphi 7.0 (Build8.1)
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Adding text to video

Post by Sergey Tkachenko »

I confirm the problem.

Quick fix:
Open MRVWinWebCamera.pas.
Find the line:
bmp.Modified := TRUE;
Add after:
bmp.ModifiedData := TRUE;

A critical section is not needed.
kennyJeon
Posts: 4
Joined: Fri Jun 16, 2023 8:32 am

Re: Adding text to video

Post by kennyJeon »

Resolved

bmp.ModifiedData := TRUE;

Added and confirmed no issues

Thank you
Post Reply