Zobrazit předchozí téma :: Zobrazit následující téma |
Autor |
Zpráva |
maxi-cx75 kolemjdoucí
Založen: 24. 11. 2006 Příspěvky: 8 Bydliště: Poland
1.00 SMM
|
Zaslal: st leden 31, 2007 2:25 pm Předmět: How to capture photos like in Papua Utils? |
|
|
Hi,
I'm a young programmer and I'm already working about a program called Siemens Webcam Utility. I need a source code that can capture image from phone's camera and save it on a hard drive, like in Papua Utils. I'm using Delphi 7.
And I've got one more question. How to send commands (for example AT+CGMM) to mobile? And how to get answers? I'm thinking about something like HyperTerminal.
Can anyone help me? _________________ AlleJaja.yoyo.pl admin
DHTML & PHP programmer
Vista Premium user
P O L A N D ! ! ! |
|
Návrat nahoru |
|
|
BEZY čestný člen
Založen: 20. 07. 2004 Příspěvky: 4348 Bydliště: Karlovy Vary
81.16 SMM
|
Zaslal: st leden 31, 2007 2:57 pm Předmět: |
|
|
Hi, for Delphi I recomend this library:
http://www.torry.net/vcl/comms/modems/cport310.zip
u can use write or writeStr commands. If you want to read data from port, just place read or readstr into OnRxChar method. (just a hint - this method should happen everytime data arrive into buffure, but it might be unstable - I myself use a Timer with this code:
kód: | if port.InputCount > 0 then
PortRxChar(port, port.InputCount) |
About a code for camera capture - try using Portmon a find out what commands is Papua Utils using
good luck _________________ C35i -> M35i -> M50 -> CX65 -> SX1McLaren -> SXG75 -> HTC HD
http://www.bezysoftware.net
Brew Mobile Commander 2.0 |
|
Návrat nahoru |
|
|
maxi-cx75 kolemjdoucí
Založen: 24. 11. 2006 Příspěvky: 8 Bydliště: Poland
1.00 SMM
|
Zaslal: st leden 31, 2007 5:51 pm Předmět: |
|
|
Portmon's log with two frames is here:
http://www.mikomiks.yoyo.pl/2_frames.log
I think these brackets and dots (unknown ASCII characters) are parts of an image, but I don't know how to decode that.[/code] _________________ AlleJaja.yoyo.pl admin
DHTML & PHP programmer
Vista Premium user
P O L A N D ! ! ! |
|
Návrat nahoru |
|
|
gehstock kolemjdoucí
Založen: 30. 03. 2006 Příspěvky: 3
1.00 SMM
|
Zaslal: st leden 31, 2007 7:15 pm Předmět: |
|
|
kód: | procedure TFormMain.ButtonGetCamClick(Sender: TObject);
var
i,x : integer;
addr,size : dword;
begin
if FixPage<>-1 then begin
FormCamera.Off := True;
ButtonStartCamera.Enabled:=False;
AddLinesLog('Stope...');
exit;
end;
PageControl.ActivePageIndex:=6;
FormCamera.Off := False;
FixPage:=PageControl.ActivePageIndex;
// ButtonStartCamera.Enabled:=False;
// PageControl.Enabled:=False;
i:=1;
ButtonStartCamera.Caption:='Stop';
StatusBar.Panels[PanelCmd].Text:='Initialisierung der Kamera...';
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
ProgressBar.Position:=10;
if ComOpen then begin
// Application.ProcessMessages;
ProgressBar.Position:=20;
Application.ProcessMessages;
BFC_SecurityMode;
if BFC_Error<>ERR_NO then begin
StatusBar.Panels[PanelCmd].Text:='Bekomme keine Antwort von der Status Nachfrage!';
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
ErrEndCamClick;
exit;
end;
Application.ProcessMessages;
if Not((bSecyrMode=$11) or (bSecyrMode=$12) or (bSecyrMode = $13)) then begin
StatusBar.Panels[PanelCmd].Text:='Nur mit berechneten SKEY möglich!';
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
ErrEndCamClick;
exit;
end;
if NOT BFC_ReadCameraId(CamParams.id) then begin
StatusBar.Panels[PanelCmd].Text:='Kann Kamera Sensor nicht erkennen!';
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
ErrEndCamClick;
exit;
end;
x:=CamParams.id;
if (x>14) or (x<0) then x:=0;
AddLinesLog('Camera sensor ID('+IntToStr(CamParams.id)+'): '+sCameraSensor[x]);
NewCamParams;
Sleep(200);
ProgressBar.Position:=30;
Application.ProcessMessages;
if NOT SetCameraParameters then begin
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
ErrEndCamClick;
exit;
end;
Application.ProcessMessages;
for x:=1 to 15 do begin
ProgressBar.StepBy(4);
Sleep(100);
Application.ProcessMessages;
end;
BFC_InitHost($06);
Sleep(100);
ProgressBar.StepBy(4);
Application.ProcessMessages;
if NOT TakeCameraPicture then begin
ErrEndCamClick;
Exit;
end;
StatusBar.Panels[PanelCmd].Text:='Empfange Daten...';
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
Application.ProcessMessages;
// ProgressBar.Position:=95;
Application.ProcessMessages;
if NOT ReadCameraToMemStream then begin
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
ErrEndCamClick;
exit;
end;
// ComClose;
// FormCamera.ClientHeight:=240;
// FormCamera.ClientWidth:=320;
FormCamera.Image.Picture.Graphic.LoadFromStream(CameraMemStream);
FormCamera.Caption:='Jpeg: '+IntToStr(FormCamera.Image.Picture.Width)+
'x'+IntToStr(FormCamera.Image.Picture.Height)+
', '+IntToStr(CameraMemStream.Size)+' bytes';
StatusBar.Panels[PanelCmd].Text:='Bilder '+IntToStr(i);
FormCamera.Show;
if CheckBoxAutoSaveJpeg.Checked then begin
if NOT AutoSaveJpegCamera then begin
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
ErrEndCamClick;
exit;
end;
end;
ButtonShowFormCam.Enabled:=True;
While not FormCamera.Off do begin
Application.ProcessMessages;
if NOT CheckCameraParameters then begin
ErrEndCamClick;
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
Exit;
end;
Application.ProcessMessages;
for x:=1 to SpinEditTO.Value do begin
Sleep(100);
Application.ProcessMessages;
end;
if NOT TakeCameraPicture then begin
ErrEndCamClick;
Exit;
end;
if NOT ReadCameraToMemStream then begin
ErrEndCamClick;
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
exit;
end;
FormCamera.Image.Picture.Graphic.LoadFromStream(CameraMemStream);
FormCamera.Caption:='Jpeg: '+IntToStr(FormCamera.Image.Picture.Width)+
'x'+IntToStr(FormCamera.Image.Picture.Height)+
', '+IntToStr(CameraMemStream.Size)+' bytes';
if CheckBoxAutoSaveJpeg.Checked then begin
if NOT AutoSaveJpegCamera then begin
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
ErrEndCamClick;
exit;
end;
end;
inc(i);
StatusBar.Panels[PanelCmd].Text:='Bilder '+IntToStr(i);
end; // While
AddLinesLog('Shutdown Camera...');
if NOT BFC_GetCameraBuf(addr,size) then begin
AddLinesLog('Warning: Fehler kann Datenpuffer nicht freigeben!');
end;
{
If (size<>0) and (CamParams.id=7) then begin
AddLinesLog('Warning('+IntToStr(size)+'): íåóäà÷íîå îñâîáîæäåíèå áóôåðà êàäðà â òåëåôîíå!');
end;
}
if NOT BFC_ShutdownCamera then begin
AddLinesLog('Error Shutdown Camera!');
end else begin
StatusBar.Panels[PanelCmd].Text:='Kamera ist offen.';
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
AddLinesLog('Alle Daten: '+IntToStr(i)+'.');
end;
ComClose;
if NOT CheckBoxAutoSaveJpeg.Checked then SaveJpegCamera;
ProgressBar.Max:=100;
end; // if ComOpen
ErrEndCamClick;
end;
function TFormMain.TakeCameraPicture : boolean;
var
size : dword;
begin
result:=False;
if NOT BFC_TakeCameraPicture(CamParams.Resolution,size) then begin
StatusBar.Panels[PanelCmd].Text:='Fehler beim Datenempfang!';
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
exit;
end;
if size=0 then begin
AddLinesLog('Timeout 0.7 sec...');
Sleep(700);
if NOT BFC_TakeCameraPicture(CamParams.Resolution,size) then begin
StatusBar.Panels[PanelCmd].Text:='Fehler beim Datenenpfang!';
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
exit;
end;
if size=0 then begin
StatusBar.Panels[PanelCmd].Text:='Keine Anzeige möglich!';
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
AddLinesLog('Mögliche Gründe:');
AddLinesLog('1) Falscher Parameter.');
AddLinesLog('2) Zeitüberschreitung.');
exit;
end;
end;
result:=True;
end;
function TFormMain.SaveJpegCamera : boolean;
var
F : TFileStream;
begin
result:=False;
if (CameraMemStream=nil) or (CameraMemStream.Size=0) then exit;
FormCamera.Show;
StatusBar.Panels[PanelCmd].Text:='Bild speichern ca. '+IntToStr(CameraMemStream.Size)+ ' Byte...';
with SaveDialog do begin
FilterIndex:=0;
FileName := IniFile.ReadString('Setup','OldCamFile','.\Camera1.jpg');
InitialDir := ExtractFilePath(FileName);
FileName := ChangeFileExt(ExtractFileName(FileName),'');
if InitialDir = '' then IniFile.ReadString('Setup','DirOld','.\');
if not DirectoryExists(InitialDir) then
InitialDir := IniFile.ReadString('Setup','DirOld','.\');
DefaultExt := 'jpg';
Filter := 'Jpeg files (*.jpg)|*.jpg';
Options:=Options+[ofFileMustExist]-[ofHideReadOnly]
+[ofNoChangeDir]-[ofNoLongNames]-[ofNoNetworkButton]-[ofHideReadOnly]
-[ofOldStyleDialog]-[ofOverwritePrompt]+[ofPathMustExist]
-[ofReadOnly]-[ofShareAware]-[ofShowHelp];
Title:='Bild speichern ca. '+IntToStr(CameraMemStream.Size)+ ' Byte';
end;//with
if SaveDialog.Execute then begin
F:=TFileStream.Create(SaveDialog.FileName,fmCreate);
CameraMemStream.Seek(0,soFromBeginning);
if F.CopyFrom(CameraMemStream,CameraMemStream.Size)<> CameraMemStream.Size
then begin
StatusBar.Panels[PanelCmd].Text:='Fehler in der Datei '+SaveDialog.FileName+'!';
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
F.Free;
exit;
end;
F.Free;
StatusBar.Panels[PanelCmd].Text:='Bilder speichern '+SaveDialog.FileName;
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
IniFile.WriteString('Setup','OldCamFile',SaveDialog.FileName);
exit;
end // if SaveDialog.Execute
else StatusBar.Panels[PanelCmd].Text:='?';
result:=True;
end;
function TFormMain.AutoSaveJpegCamera : boolean;
var
F : TFileStream;
sJpgFile : string;
begin
result:=False;
if (CameraMemStream=nil) or (CameraMemStream.Size=0) then exit;
sJpgFile:='.\Jpegs';
if not DirectoryExists(sJpgFile) then begin
if not CreateDir(sJpgFile) then sJpgFile := '.';
end;
sJpgFile:=sJpgFile+'\'+FormatDateTime('yymmddhhnnsszzz',Now)+'.jpg';
// try
F:=TFileStream.Create(sJpgFile,fmCreate);
CameraMemStream.Seek(0,soFromBeginning);
if F.CopyFrom(CameraMemStream,CameraMemStream.Size)<> CameraMemStream.Size
then begin
StatusBar.Panels[PanelCmd].Text:='Fehler beim Speichern '+SaveDialog.FileName+'!';
AddLinesLog(StatusBar.Panels[PanelCmd].Text);
F.Free;
exit;
end;
// finally
F.Free;
// end;
result:=True;
end;
procedure TFormMain.ErrEndCamClick;
begin
if CameraMemStream<>nil then begin
CameraMemStream.Free; CameraMemStream:=nil;
end;
ButtonShowFormCam.Enabled:=False;
ButtonStartCamera.Caption:='Start';
ButtonStartCamera.Enabled:=True;
FixPage:=-1;
ComClose;
end;
function TFormMain.ReadCameraToMemStream : boolean;
var
addr,size,len : dword;
Buf : array[0..$fff] of Byte;
begin
result:=False;
if CameraMemStream=nil then CameraMemStream:=TMemoryStream.Create
else CameraMemStream.Seek(0,soFromBeginning);
if NOT BFC_GetCameraBuf(addr,size) then begin
StatusBar.Panels[PanelCmd].Text:='Fehler im Datenpuffer!';
exit;
end;
// AddLinesLog('Àäðåñ áóôåðà êàäðà: 0x'+IntToHex(addr,8));
// AddLinesLog('Ðàçìåð êàäðà '+IntToStr(size)+ ' áàéò.');
if (size=0) or (addr=0) then begin
StatusBar.Panels[PanelCmd].Text:='Datenpuffer ist gleich groß!';
exit;
end;
if size>1024*1024 then begin
StatusBar.Panels[PanelCmd].Text:='Datenpuffer hat falsche Größe!';
exit;
end;
ProgressBar.Max:=1 + (size div sizeof(buf));
ProgressBar.Position:=1;
Application.ProcessMessages;
// Repaint;
CameraMemStream.SetSize(size);
// CameraMemStream.Seek(0,soFromBeginning);
while size>0 do begin
Application.ProcessMessages;
len:=sizeof(Buf);
if size<len then len:=size;
if NOT BFCReadMem(addr,len,Buf[0]) then begin
AddLinesLog('Lese Blockinhalt...');
if NOT BFCReadMem(addr,len,Buf[0]) then begin
StatusBar.Panels[PanelCmd].Text:='Fehler beim lesen 0x'+IntToHex(addr,8)+'!';
CameraMemStream.Free; CameraMemStream:=nil;
ProgressBar.Max:=100;
exit;
end;
end;
if CameraMemStream.Write(Buf,len)<>integer(len) then begin
StatusBar.Panels[PanelCmd].Text:='MemoryStream: Fehler beim lesen!';
CameraMemStream.Free; CameraMemStream:=nil;
ProgressBar.Max:=100;
exit;
end;
ProgressBar.StepBy(1); //max +64
addr:=addr+len;
size:=size-len;
end; // while
{
if NOT BFC_GetCameraBuf(addr,size) then begin
AddLinesLog('Fehler îñâîáîæäåíèÿ áóôåðà êàäðà â òåëåôîíå!');
end;
If (size<>0) then begin
AddLinesLog('Fehler('+IntToStr(size)+') îñâîáîæäåíèÿ áóôåðà êàäðà â òåëåôîíå!');
end;
}
CameraMemStream.Seek(0,soFromBeginning);
ProgressBar.Max:=100;
ProgressBar.Position:=100;
result:=True;
end;
procedure TFormMain.NewCamParams;
begin
CamParams.WhiteBalance:=CamWhiteBalance.ItemIndex;
CamParams.Brightness:=ScrollBarBrigh.Position;
CamParams.CompressionRate:=CamCompressionRate.ItemIndex;
CamParams.ZoomFactor:= CamZoomFactor.ItemIndex+1;
CamParams.ColorMode := CamColorMode.ItemIndex;
CamParams.Resolution := CameraPicResolution.ItemIndex;
if CamFlashCondition.Checked then CamParams.FlashCondition := 1
else CamParams.FlashCondition:=0;
{
AddLinesLog('WhiteBalance: '+IntToStr(CamParams.WhiteBalance));
AddLinesLog('Brightness: '+IntToStr(CamParams.Brightness));
AddLinesLog('CompressionRate: '+IntToStr(CamParams.CompressionRate));
AddLinesLog('ZoomFactor: '+IntToStr(CamParams.ZoomFactor));
AddLinesLog('ColorMode: '+IntToStr(CamParams.ColorMode));
AddLinesLog('FlashCondition: '+IntToStr(CamParams.FlashCondition));
}
end;
function TFormMain.SetCameraParameters : boolean;
begin
result:=False;
if NOT BFC_SetCameraParameters(0,CamParams.WhiteBalance) then begin
StatusBar.Panels[PanelCmd].Text:='Fehler in den Parametern vom Weißabgleich!';
exit;
end;
if NOT BFC_SetCameraParameters(1,CamParams.Brightness) then begin
StatusBar.Panels[PanelCmd].Text:='Fehler in den Parametern von der Helligkeit!';
exit;
end;
if NOT BFC_SetCameraParameters(2,CamParams.CompressionRate) then begin
StatusBar.Panels[PanelCmd].Text:='Fehler Fehler in den Parametern von der Kompressionsrate!';
exit;
end;
if NOT BFC_SetCameraParameters(3,CamParams.ZoomFactor) then begin
StatusBar.Panels[PanelCmd].Text:='Fehler in den Parametern vom Zoom!';
exit;
end;
if NOT BFC_SetCameraParameters(4,CamParams.ColorMode) then begin
StatusBar.Panels[PanelCmd].Text:='Fehler Fehler in den Parametern vom Farbmodus!';
exit;
end;
if CamParams.FlashCondition > 0 then
if NOT BFC_SetCameraParameters(5,CamParams.FlashCondition) then begin
StatusBar.Panels[PanelCmd].Text:='Fehler: Kamera hat keinen Blitz!';
exit;
end;
result:=True;
end;
function TFormMain.CheckCameraParameters : boolean;
var
OldCamParams: T_CamParamVal;
begin
result:=False;
OldCamParams:=CamParams;
NewCamParams;
if OldCamParams.WhiteBalance<>CamParams.WhiteBalance then begin
if NOT BFC_SetCameraParameters(0,CamParams.WhiteBalance) then begin
StatusBar.Panels[PanelCmd].Text:='Fehler in den Parametern vom Weißabgleich!';
exit;
end;
end;
if OldCamParams.Brightness<>CamParams.Brightness then begin
if NOT BFC_SetCameraParameters(1,CamParams.Brightness) then begin
StatusBar.Panels[PanelCmd].Text:='Fehler in den Parametern von der Helligkeit!';
exit;
end;
sleep(500);
end;
if OldCamParams.CompressionRate<>CamParams.CompressionRate then begin
if NOT BFC_SetCameraParameters(2,CamParams.CompressionRate) then begin
StatusBar.Panels[PanelCmd].Text:='Fehler in den Parametern von der Kompressionsrate!';
exit;
end;
end;
if OldCamParams.ZoomFactor<>CamParams.ZoomFactor then begin
if NOT BFC_SetCameraParameters(3,CamParams.ZoomFactor) then begin
StatusBar.Panels[PanelCmd].Text:='Fehler in den Parametern vom Zoom!';
exit;
end;
end;
if OldCamParams.ColorMode<>CamParams.ColorMode then begin
if NOT BFC_SetCameraParameters(4,CamParams.ColorMode) then begin
StatusBar.Panels[PanelCmd].Text:='Fehler in den Parametern vom Farbmodus!';
exit;
end;
end;
if OldCamParams.FlashCondition<>CamParams.FlashCondition then begin
if CamParams.FlashCondition > 0 then
if NOT BFC_SetCameraParameters(5,CamParams.FlashCondition) then begin
StatusBar.Panels[PanelCmd].Text:='Fehler: Kamera hat keinen Blitz!';
exit;
end;
// Sleep(200);
end;
result:=True;
end; |
|
|
Návrat nahoru |
|
|
BEZY čestný člen
Založen: 20. 07. 2004 Příspěvky: 4348 Bydliště: Karlovy Vary
81.16 SMM
|
Zaslal: st leden 31, 2007 8:05 pm Předmět: |
|
|
maxi-cx75 napsal: | Portmon's log with two frames is here:
http://www.mikomiks.yoyo.pl/2_frames.log
I think these brackets and dots (unknown ASCII characters) are parts of an image, but I don't know how to decode that.[/code] |
You have to switch to HEX, find out what is the header and use the rest as the image itself.
Or use the given source code _________________ C35i -> M35i -> M50 -> CX65 -> SX1McLaren -> SXG75 -> HTC HD
http://www.bezysoftware.net
Brew Mobile Commander 2.0 |
|
Návrat nahoru |
|
|
maxi-cx75 kolemjdoucí
Založen: 24. 11. 2006 Příspěvky: 8 Bydliště: Poland
1.00 SMM
|
Zaslal: pá únor 02, 2007 4:10 pm Předmět: |
|
|
gehstock, can you give me full PU's source? These are some functions and variables used in this code you didn't attach.
Of course I'll add your nicks to 'about' window. _________________ AlleJaja.yoyo.pl admin
DHTML & PHP programmer
Vista Premium user
P O L A N D ! ! ! |
|
Návrat nahoru |
|
|
gehstock kolemjdoucí
Založen: 30. 03. 2006 Příspěvky: 3
1.00 SMM
|
|
Návrat nahoru |
|
|
maxi-cx75 kolemjdoucí
Založen: 24. 11. 2006 Příspěvky: 8 Bydliště: Poland
1.00 SMM
|
Zaslal: ne únor 04, 2007 12:56 pm Předmět: |
|
|
I konw, but I don't understand any russian word _________________ AlleJaja.yoyo.pl admin
DHTML & PHP programmer
Vista Premium user
P O L A N D ! ! ! |
|
Návrat nahoru |
|
|
alkaba čestný člen
Založen: 15. 01. 2005 Příspěvky: 1618 Bydliště: 0x0000FFF Telefon: S75
10903.00 SMM
|
|
Návrat nahoru |
|
|
maxi-cx75 kolemjdoucí
Založen: 24. 11. 2006 Příspěvky: 8 Bydliště: Poland
1.00 SMM
|
Zaslal: ne únor 04, 2007 3:36 pm Předmět: |
|
|
thanks, that's it _________________ AlleJaja.yoyo.pl admin
DHTML & PHP programmer
Vista Premium user
P O L A N D ! ! ! |
|
Návrat nahoru |
|
|
|
|
Nemůžete odesílat nové téma do tohoto fóra Nemůžete odpovídat na témata v tomto fóru Nemůžete upravovat své příspěvky v tomto fóru Nemůžete mazat své příspěvky v tomto fóru Nemůžete hlasovat v tomto fóru Můžeš k příspěvkům připojovat soubory Můžeš stahovat a prohlížet přiložené soubory
|
Powered by phpBB © phpBB Group
|