Bonjour à toutes et à tous,
Avec mon application, je récupère l'image de ma webcam sur une page html créée dynamiquement.
Cela fonctionne correctement mais c'est toute la page qui est rafraîchie.
Est t'il possible de ne rafraîchir que l'image envoyée ?
Mon code :
Interpréteur
Création de la page web :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 procedure TFServer.Interpreteur(AThread: TIdPeerThread; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); begin //******demande de la page créé dynamiquement // on aurait pu aussi la demander sous sa forme fichier HTML // par ServeFile(AResponseInfo,'firstpage.htm'); if pos('firstpage',ARequestInfo.Document)<>0 then begin sendPage(ARequestInfo ,AResponseInfo); // memo1.lines.Add('firstpage demandée '); exit; end; //demande d'une image dynamique if pos('Image',ARequestInfo.Document)<>0 then begin ServeCamera(ARequestInfo ,AResponseInfo); // memo1.lines.Add('Image demandée '); exit; end; //demande de l'icone (image statique)-->envoi d'un ficher if pos('favico',ARequestInfo.Document)<>0 then begin ServeFile(AResponseInfo,'video.ico'); exit; end; //*** on peut ainsi rajouter autant de commandes que l'on desire end;
Création du Jpeg :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65 procedure TFServer.sendPage(ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); var u:string; u1,t1,t2:integer; begin //**********creation dynamique de la page u:='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'#10#13+ #10#13+ '<html>'#10#13+ '<head>'#10#13+ '<title>SURVEILLANCE</title>'#10#13+ //***********mise à jour du taux de rafraichissement********************** '<META http-equiv="Refresh" content="'+inttostr(Ed_refresh.Value)+'">'#10#13+ '</head>'#10#13+ '<body ms_positioning="gridlayout">'#10#13+ '<p align="center"><font face="Arial Narrow" size="4">SURVEILLANCE</font>'#10#13+ '</p>'#10#13; if alarme then begin t1:=60; u:=u+'<p align="center"><font face="Arial Narrow" size="6">ALERTE INTRUSION</font>'#10#13+ '</p>'#10#13; end else t1:=0; u:=u+'<p align="center"> </p><img'#10#13+ 'style="Z-INDEX: 101; LEFT: 40px; WIDTH: 259px; POSITION: absolute; TOP: '+inttostr (30+t1)+'px; HEIGHT: 211px"'#10#13+ 'height="35" alt="" src="Image1" width="27">'#10#13; if NbCamera>1 then begin u:=u+'<p align="center"> </p><img'#10#13+ 'style="Z-INDEX: 101; LEFT: 319px; WIDTH: 259px; POSITION: absolute; TOP: '+inttostr (30+t1)+'px; HEIGHT: 211px"'#10#13+ 'height="35" alt="" src="Image2" width="27">'#10#13; end; if NbCamera>2 then begin if NbCamera=4 then u1:= 40 else u1:= 180; u:=u+'<p align="center"> </p><img'#10#13+ 'style="Z-INDEX: 101; LEFT: '+inttostr(u1)+'; WIDTH: 259px; POSITION: absolute; TOP: '+inttostr(260+t1)+'px; HEIGHT: 211px"'#10#13+ 'height="35" alt="" src="Image3" width="27">'#10#13; end; if NbCamera=4 then begin u:=u+'<p align="center"> </p><img'#10#13+ 'style="Z-INDEX: 101; LEFT: 319px; WIDTH: 259px; POSITION: absolute; TOP: 260px; HEIGHT: '+inttostr(260+t1)+'px"'#10#13+ 'height="35" alt="" src="Image4" width="27">'#10#13; end; u:=u+'</body>'#10#13+ '</html>'#10#13; //************************* envoi de la page ************************* AResponseInfo.ContentStream:=TStringStream.Create(u); end;
Merci d'avance si il y a une solution.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 procedure TFServer.ServeCamera(ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); var jpg1:TjpegImage; m:TMemoryStream; NumImage:integer; begin //récupération du N° d'image NumImage:=strtoint(copy(ARequestInfo.Document,pos('Image', ARequestInfo.Document)+length('Image'),10)); m:=TMemoryStream.Create; Jpg1 := TjpegImage.Create; Jpg1.Assign(ScanBitmap[NumImage]); Jpg1.CompressionQuality := Ed_Quality.Value; Jpg1.SaveToStream(m);//on met dans le stream Jpg1.Free; //**** en final on envoie l'image AResponseInfo.ContentStream:=m; end;
@+,
Cincap
Partager