mirror of
https://github.com/Laex/Delphi-OpenCV.git
synced 2024-11-15 07:45:53 +01:00
Fixed components samples
Signed-off-by: Mikhail Grigorev <sleuthhound@gmail.com>
This commit is contained in:
parent
cbf678e913
commit
e917bab621
Binary file not shown.
@ -145,10 +145,9 @@ object MainForm: TMainForm
|
||||
Top = 40
|
||||
end
|
||||
object ocvpcmsrc1: TocvIPCamSource
|
||||
UserName = 'admin'
|
||||
Password = 'admin'
|
||||
IP = '10.1.1.202'
|
||||
URI = '/cam/realmonitor?channel=1&subtype=0'
|
||||
IP = '80.78.116.125'
|
||||
URI = '/rtplive/plot_hd.stream'
|
||||
Port = 1935
|
||||
Left = 336
|
||||
Top = 44
|
||||
end
|
||||
|
Binary file not shown.
@ -2,8 +2,8 @@ object Form1: TForm1
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'FFMpeg IP Camera source'
|
||||
ClientHeight = 194
|
||||
ClientWidth = 229
|
||||
ClientHeight = 376
|
||||
ClientWidth = 378
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
@ -11,25 +11,52 @@ object Form1: TForm1
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poScreenCenter
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnShow = FormShow
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object ocvView1: TocvView
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 229
|
||||
Height = 194
|
||||
Top = 41
|
||||
Width = 378
|
||||
Height = 335
|
||||
VideoSource = ocvFFMpegIPCamSource1
|
||||
Frames = <>
|
||||
Align = alClient
|
||||
ExplicitTop = 56
|
||||
ExplicitWidth = 229
|
||||
ExplicitHeight = 224
|
||||
end
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 378
|
||||
Height = 41
|
||||
Align = alTop
|
||||
Caption = 'Panel1'
|
||||
TabOrder = 1
|
||||
ExplicitWidth = 185
|
||||
DesignSize = (
|
||||
378
|
||||
41)
|
||||
object CBCameraSampleList: TComboBox
|
||||
Left = 16
|
||||
Top = 9
|
||||
Width = 345
|
||||
Height = 21
|
||||
Style = csDropDownList
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
TabOrder = 0
|
||||
OnChange = CBCameraSampleListChange
|
||||
end
|
||||
end
|
||||
object ocvFFMpegIPCamSource1: TocvFFMpegIPCamSource
|
||||
Enabled = True
|
||||
UserName = 'admin'
|
||||
Password = 'admin'
|
||||
IP = '10.1.1.201'
|
||||
URI = '/Streaming/Channels/1?transportmode=unicast'
|
||||
Port = 1935
|
||||
OnLostConnection = ocvFFMpegIPCamSource1LostConnection
|
||||
Left = 104
|
||||
Top = 96
|
||||
ReconnectDelay = 1500
|
||||
Left = 264
|
||||
Top = 56
|
||||
end
|
||||
end
|
||||
|
@ -5,29 +5,206 @@ interface
|
||||
uses
|
||||
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
||||
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, ffm.libavcodec.avcodec,
|
||||
ocv.comp.Types, ocv.comp.Source, ocv.comp.View;
|
||||
ocv.comp.Types, ocv.comp.Source, ocv.comp.View, Vcl.StdCtrls, Vcl.ExtCtrls;
|
||||
|
||||
type
|
||||
TSampleCameraStruct = record
|
||||
Alias: String;
|
||||
IP: String;
|
||||
Port: Word;
|
||||
Protocol: TocvIPProtocol;
|
||||
URI: String;
|
||||
ReconnectDelay: Integer;
|
||||
UserName: String;
|
||||
Password: String;
|
||||
end;
|
||||
PSampleCameraStruct = ^TSampleCameraStruct;
|
||||
TForm1 = class(TForm)
|
||||
ocvFFMpegIPCamSource1: TocvFFMpegIPCamSource;
|
||||
ocvView1: TocvView;
|
||||
Panel1: TPanel;
|
||||
CBCameraSampleList: TComboBox;
|
||||
procedure ocvFFMpegIPCamSource1LostConnection(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure CBCameraSampleListChange(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
private
|
||||
LCCount: Integer;
|
||||
FList: TList;
|
||||
procedure DrawText(Value: String);
|
||||
public
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
const
|
||||
// Äàííûå âçÿòû ñ ñàéòà http://myttk.ru/media/webcam/ ñ ïîìîùüþ Wireshark
|
||||
// Ïðîâåðåíû ñ ïîìîùüþ rtmpdump - http://all-streaming-media.com/record-video-stream/rtmpdump-freeware-console-RTMP-downloading-application.htm
|
||||
SampleCameraList: Array [0..5] of String =(
|
||||
'alias=Ekaterinburg - Area 1905|'+
|
||||
'ip=80.78.116.125|'+
|
||||
'port=1935|'+
|
||||
'protocol=2|'+ // 0 - http, 1 - https, 2 - rtsp
|
||||
'uri=/rtplive/5goda_hd.stream|'+
|
||||
'reconnectdelay=1500|'+
|
||||
'username=|'+
|
||||
'password=',
|
||||
|
||||
'alias=Ekaterinburg - Plotinka|'+
|
||||
'ip=80.78.116.125|'+
|
||||
'port=1935|'+
|
||||
'protocol=2|'+
|
||||
'uri=/rtplive/plot_hd.stream|'+
|
||||
'reconnectdelay=1500|'+
|
||||
'username=|'+
|
||||
'password=',
|
||||
|
||||
'alias=Zoo - Elephant Dasha|'+
|
||||
'ip=80.78.116.125|'+
|
||||
'port=1935|'+
|
||||
'protocol=2|'+
|
||||
'uri=/rtplive/zoo_ek_sd.stream|'+
|
||||
'reconnectdelay=1500|'+
|
||||
'username=|'+
|
||||
'password=',
|
||||
|
||||
'alias=Lake Baikal, Listvyanka|'+
|
||||
'ip=stream.baikal-online.ru|'+
|
||||
'port=1935|'+
|
||||
'protocol=2|'+
|
||||
'uri=/live/list.stream|'+
|
||||
'reconnectdelay=3500|'+
|
||||
'username=|'+
|
||||
'password=',
|
||||
|
||||
'alias=Chita, Square Love and Faithfulness|'+
|
||||
'ip=188.168.81.103|'+
|
||||
'port=1935|'+
|
||||
'protocol=2|'+
|
||||
'uri=/rtplive/Skver-Love.stream|'+
|
||||
'reconnectdelay=3500|'+
|
||||
'username=|'+
|
||||
'password=',
|
||||
|
||||
'alias=Solikamsk, Cathedral Square|'+
|
||||
'ip=80.78.116.125|'+
|
||||
'port=1935|'+
|
||||
'protocol=2|'+
|
||||
'uri=/rtplive/solikamsk_hd.stream|'+
|
||||
'reconnectdelay=2500|'+
|
||||
'username=|'+
|
||||
'password='
|
||||
);
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm}
|
||||
|
||||
function GetValue(Value: String): String;
|
||||
var
|
||||
P: Integer;
|
||||
begin
|
||||
P := Pos('=', Value);
|
||||
Result := Trim(Copy(Value, P+1, Length(Value)));
|
||||
end;
|
||||
|
||||
function GetParam(var Value: String): String;
|
||||
var
|
||||
P: Integer;
|
||||
begin
|
||||
P := Pos('|', Value);
|
||||
if P > 0 then
|
||||
Result := Trim(Copy(Value, 1, P-1))
|
||||
else
|
||||
Result := Trim(Copy(Value, 1, Length(Value)));
|
||||
Delete(Value, 1, P);
|
||||
end;
|
||||
|
||||
function GetProto(Value: Integer): TocvIPProtocol;
|
||||
begin
|
||||
case Value of
|
||||
0: Result := ippHTTP;
|
||||
1: Result := ippHTTPS;
|
||||
2: Result := ippRTSP;
|
||||
else
|
||||
Result := ippRTSP;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
var
|
||||
Cnt: Integer;
|
||||
Cam: PSampleCameraStruct;
|
||||
Str: String;
|
||||
begin
|
||||
FList := TList.Create;
|
||||
FList.Clear;
|
||||
for Cnt := 0 to Length(SampleCameraList)-1 do
|
||||
begin
|
||||
New(Cam);
|
||||
Str := SampleCameraList[Cnt];
|
||||
Cam^.Alias := GetValue(GetParam(Str));
|
||||
Cam^.IP := GetValue(GetParam(Str));
|
||||
Cam^.Port := StrToIntDef(GetValue(GetParam(Str)), 0);
|
||||
Cam^.Protocol := GetProto(StrToIntDef(GetValue(GetParam(Str)), 0));
|
||||
Cam^.URI := GetValue(GetParam(Str));
|
||||
Cam^.ReconnectDelay := StrToIntDef(GetValue(GetParam(Str)), 0);
|
||||
Cam^.UserName := GetValue(GetParam(Str));
|
||||
Cam^.Password := GetValue(GetParam(Str));
|
||||
FList.Add(Cam);
|
||||
end;
|
||||
if FList.Count > 0 then
|
||||
begin
|
||||
CBCameraSampleList.Clear;
|
||||
CBCameraSampleList.Items.BeginUpdate;
|
||||
try
|
||||
for Cnt := 0 to FList.Count-1 do
|
||||
CBCameraSampleList.Items.Add(TSampleCameraStruct(FList[Cnt]^).Alias);
|
||||
finally
|
||||
CBCameraSampleList.Items.EndUpdate;
|
||||
end;
|
||||
CBCameraSampleList.ItemIndex := -1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
CBCameraSampleList.ItemIndex := -1;
|
||||
CBCameraSampleList.Enabled := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
FList.Free;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormShow(Sender: TObject);
|
||||
begin
|
||||
DrawText('Please select the camera.')
|
||||
end;
|
||||
|
||||
procedure TForm1.CBCameraSampleListChange(Sender: TObject);
|
||||
var
|
||||
Cam: TSampleCameraStruct;
|
||||
begin
|
||||
DrawText('Getting data, please wait...');
|
||||
ocvFFMpegIPCamSource1.Enabled := False;
|
||||
Cam := TSampleCameraStruct(FList[(Sender as TComboBox).ItemIndex]^);
|
||||
ocvFFMpegIPCamSource1.IP := Cam.IP;
|
||||
ocvFFMpegIPCamSource1.Port := Cam.Port;
|
||||
ocvFFMpegIPCamSource1.Protocol := Cam.Protocol;
|
||||
ocvFFMpegIPCamSource1.URI := Cam.URI;
|
||||
ocvFFMpegIPCamSource1.ReconnectDelay := Cam.ReconnectDelay;
|
||||
ocvFFMpegIPCamSource1.UserName := Cam.UserName;
|
||||
ocvFFMpegIPCamSource1.Password := Cam.Password;
|
||||
ocvFFMpegIPCamSource1.Enabled := True;
|
||||
end;
|
||||
|
||||
procedure TForm1.ocvFFMpegIPCamSource1LostConnection(Sender: TObject);
|
||||
Const
|
||||
const
|
||||
LostConText = 'Lost connection ';
|
||||
Var
|
||||
var
|
||||
TW: Integer;
|
||||
LostConBmp: TBitmap;
|
||||
begin
|
||||
@ -41,4 +218,18 @@ begin
|
||||
LostConBmp.Free;
|
||||
end;
|
||||
|
||||
procedure TForm1.DrawText(Value: String);
|
||||
var
|
||||
Bmp: TBitmap;
|
||||
TW: Integer;
|
||||
begin
|
||||
Bmp := TBitmap.Create;
|
||||
Bmp.SetSize(ocvView1.Width, ocvView1.Height);
|
||||
Bmp.PixelFormat := pf24bit;
|
||||
TW := Bmp.Canvas.TextWidth(Value);
|
||||
Bmp.Canvas.TextOut((ocvView1.Width - TW) div 2, ocvView1.Height div 2, Value);
|
||||
ocvView1.DrawImage(TocvImage.Create(Bmp));
|
||||
Bmp.Free;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user