Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 08-05-2016
AlexM AlexM is offline
Registrado
NULL
 
Registrado: dic 2015
Posts: 6
Poder: 0
AlexM Va por buen camino
¿Componente para la webcam?



Hola, estoy desarrollando un programa para windows. Una de las cosas que necesito es que en un form se vea reproducida la webcam. Se que hay un componente que se encarga de eso, pero no encuentro mucha información de este.

¿Cuál es su nombre y donde lo puedo instalar?

¡Gracias y saludos!
Responder Con Cita
  #2  
Antiguo 08-05-2016
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Poder: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Precisamente acabo de hacer una mini app que hace eso mismo: MiniWebCam

Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, Menus;

type
  TForm1 = class(TForm)
    PopupMenu1: TPopupMenu;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Exit1Click(Sender: TObject);
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Rectangle1Click(Sender: TObject);
    procedure Round1Click(Sender: TObject);
    procedure SizeClick(Sender: TObject);
  private
    hWndC : THandle;
    Round: BOOL;
  public
    procedure SetResolution(Width, Height: integer);
  end;

var
  Form1: TForm1;

  const
  WM_CAP_START                    = WM_USER;
  WM_CAP_DRIVER_CONNECT           = WM_CAP_START + 10;
  WM_CAP_DRIVER_DISCONNECT        = WM_CAP_START + 11;
  WM_CAP_GET_VIDEOFORMAT          = WM_CAP_START + 44;
  WM_CAP_SET_VIDEOFORMAT          = WM_CAP_START + 45;
  WM_CAP_SET_PREVIEW              = WM_CAP_START + 50;
  WM_CAP_SET_OVERLAY              = WM_CAP_START + 51;
  WM_CAP_SET_PREVIEWRATE          = WM_CAP_START + 52;
  WM_CAP_SET_SCALE                = WM_CAP_START + 53;

function capCreateCaptureWindowA(lpszWindowName: PCHAR; dwStyle, x, y, nWidth, nHeight: integer; ParentWin: HWND; nId: integer): HWND; stdcall external 'AVICAP32.DLL';

implementation

{$R *.dfm}
var
OldWindowProc: Pointer;

function NewWindowProc(hWnd: HWND; Msg: UINT; WParam: WPARAM; LParam: LPARAM): LRESULT; stdcall;
var
  hParent: THANDLE;
begin
  hParent:= GetParent(hWnd);
  if (Msg = WM_LBUTTONDOWN) or (Msg = WM_RBUTTONDOWN) then
  CallWindowProc(Pointer(GetWindowLong(hParent, GWL_WNDPROC)), hParent, Msg, WParam, LParam);
  Result:= CallWindowProc(OldWindowProc, hWnd, Msg, WParam, lParam);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Round:= false;
  Height:= 120;
  Width:= MulDiv(Height, 4, 3);
  hWndC := capCreateCaptureWindowA('Mi Ventana de captura', WS_CHILD or WS_VISIBLE ,0, 0, Width, Height, Handle, 0);
  if hWndC <> 0 then
  begin
    OldWindowProc:= Pointer(SetWindowLong(hWndC, GWL_WNDPROC, LongInt(@NewWindowProc)));
    SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0);
    SendMessage(hWndC, WM_CAP_SET_SCALE, 1, 0);
    SendMessage(hWndC, WM_CAP_SET_PREVIEWRATE, 40, 0);
    SendMessage(hWndC, WM_CAP_SET_OVERLAY, 1, 0);
    SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0);
//    SetResolution(320, 240);
    SetResolution(640, 480);
//    SetResolution(800, 600);
  end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if hWndC <> 0 then
    SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0);
end;

procedure TForm1.Exit1Click(Sender: TObject);
begin
  Close;
end;

procedure TForm1.SetResolution(Width, Height: integer);
var
  bi: BITMAPINFO;
begin
  SendMessage(hWndC, WM_CAP_GET_VIDEOFORMAT, sizeof(bi), Cardinal(@bi));
  bi.bmiHeader.biWidth:= Width;
  bi.bmiHeader.biHeight:= Height;

  if SendMessage(hWndC, WM_CAP_SET_VIDEOFORMAT, sizeof(bi), Cardinal(@bi)) <> 0 then
  begin
    SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0);
    SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0);
  end;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if Button = mbLeft then
  begin
    ReleaseCapture;
    Perform(WM_SYSCOMMAND, $F012, 0);
  end
  else if Button = mbRight then
    PopupMenu1.Popup(Left+X, Top+Y);
end;

procedure TForm1.Round1Click(Sender: TObject);
var
  Rgn: HRGN;
  Rect: TRect;
begin
  Round:= true;
  Rect:= ClientRect;
  Rgn:= CreateRoundRectRgn(Rect.left, Rect.top, Rect.bottom, Rect.bottom, Rect.bottom, Rect.bottom);
  SetWindowRgn(Handle, Rgn, true);
end;

procedure TForm1.Rectangle1Click(Sender: TObject);
var
  Rgn: HRGN;
  Rect: TRect;
begin
  Round:= false;
  Rect:= ClientRect;
  Rgn:= CreateRectRgn(Rect.left, Rect.top, Rect.Right, Rect.Bottom);
  SetWindowRgn(Handle, Rgn, true);
end;

procedure TForm1.SizeClick(Sender: TObject);
var
  Item: TMenuItem;
begin
  Item:= TMenuItem(Sender);
  Height:= StrToInt(StringReplace(Item.Caption, '&', '', [rfReplaceAll]));
  Width:= MulDiv(Height, 4, 3);
  if Round then Round1Click(self)
  else Rectangle1Click(self);
  SetWindowPos(hWndC, 0, 0, 0, Width, Height, SWP_SHOWWINDOW or SWP_NOZORDER);
end;

end.


Saludos.
Responder Con Cita
  #3  
Antiguo 08-05-2016
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Poder: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Si sólo te hace falta un formulario normal y corriente, lo siguiente es un ejemplo de un previsualizador en un Form sin botones ni controles. Muestra una imajen de la Webcam a una resolución de 800x600:

Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    hWndC : THandle;
  public
    procedure SetResolution(Width, Height: integer);
end;

var
  Form1: TForm1;

  const
  WM_CAP_START                    = WM_USER;
  WM_CAP_DRIVER_CONNECT           = WM_CAP_START + 10;
  WM_CAP_DRIVER_DISCONNECT        = WM_CAP_START + 11;
  WM_CAP_GET_VIDEOFORMAT          = WM_CAP_START + 44;
  WM_CAP_SET_VIDEOFORMAT          = WM_CAP_START + 45;
  WM_CAP_SET_PREVIEW              = WM_CAP_START + 50;
  WM_CAP_SET_OVERLAY              = WM_CAP_START + 51;
  WM_CAP_SET_PREVIEWRATE          = WM_CAP_START + 52;
  WM_CAP_SET_SCALE                = WM_CAP_START + 53;

function capCreateCaptureWindowA(lpszWindowName: PCHAR; dwStyle, x, y, nWidth, nHeight: integer; ParentWin: HWND; nId: integer): HWND; stdcall external 'AVICAP32.DLL';

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Width:= 400;
  Height:= 300;
  hWndC := capCreateCaptureWindowA('Mi Ventana de captura', WS_CHILD or WS_VISIBLE ,0, 0, Width, Height, Handle, 0);
  if hWndC <> 0 then
  begin
    SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0);
    SendMessage(hWndC, WM_CAP_SET_SCALE, 1, 0);
    SendMessage(hWndC, WM_CAP_SET_PREVIEWRATE, 40, 0);
    SendMessage(hWndC, WM_CAP_SET_OVERLAY, 1, 0);
    SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0);
    SetResolution(640, 480);
  end;
end;

procedure TForm1.SetResolution(Width, Height: integer);
var
  bi: BITMAPINFO;
begin
  if hWndC = 0 then exit;  

  SendMessage(hWndC, WM_CAP_GET_VIDEOFORMAT, sizeof(bi), Cardinal(@bi));
  bi.bmiHeader.biWidth:= Width;
  bi.bmiHeader.biHeight:= Height;

  if SendMessage(hWndC, WM_CAP_SET_VIDEOFORMAT, sizeof(bi), Cardinal(@bi)) <> 0 then
  begin
    SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0);
    SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0);
  end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if hWndC <> 0 then
    SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0);
end;

end.

Saludos.

Última edición por escafandra fecha: 08-05-2016 a las 17:50:49.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Alguién conoce una solución simple y confiable para la WebCam en Delphi ? rolandoj Gráficos 8 27-05-2013 09:53:56
problema con Unit para uso de webcam. look Varios 2 09-11-2012 23:43:38
componente visualizar webcam super sencillo bLiNdEN Gráficos 5 11-03-2011 16:48:32
Ayuda para instalar componente svqrbarcode para QReport BlueSteel Varios 4 24-09-2010 23:05:23
Componente para buscar registros, para no repetir codigo. flystar Conexión con bases de datos 9 28-04-2010 23:16:15


La franja horaria es GMT +2. Ahora son las 03:52:42.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi