Camera Control needed for Tablet

Re: Camera Control needed for Tablet

Postby Antonio Linares » Thu Aug 25, 2016 9:38 pm

Tim, Gale,

Are you using different Windows builds ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Camera Control needed for Tablet

Postby Gale FORd » Thu Aug 25, 2016 9:45 pm

I am using Microsoft Windows 10 Pro
Version 10.0.10586 Build 10586
x64-based PC

I will try running it on our Panasonic Touphpad with Windows 10 Pro x86 version
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Camera Control needed for Tablet

Postby TimStone » Thu Aug 25, 2016 9:57 pm

Antonio,

On my Surface 3 ( not the pro model ), I just did a complete fresh re-install so it is the actual Anniversary release. I did it yesterday. It shows as Home: 14393.82

On my desktop, it is also working. This is an Insider Fast machine, build 14095.rs_prelease.160811-1739.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Camera Control needed for Tablet

Postby Gale FORd » Thu Aug 25, 2016 10:00 pm

Works ok on Panasonic ToughPad
Windows 10 Pro 64bit
Same windows build as the one on my Surface Pro 3.
Dshow defaults to camera 2 that faces user.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Camera Control needed for Tablet

Postby Antonio Linares » Thu Aug 25, 2016 10:19 pm

Gale,

Gale FORd wrote:On my Microsoft Surface Pro 3 with Windows 10 dshow.exe gets error.
"Could not render preview video stream"
dshow.exe was in the last .zip file you linked to.


After the error, is the app working fine ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Camera Control needed for Tablet

Postby Gale FORd » Thu Aug 25, 2016 10:38 pm

It shows a black square box inside the dialog. If I click on black square it creates another black square beside it.
It also creates a 352kb photo.bmp but the image seems to be empty.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Camera Control needed for Tablet

Postby Antonio Linares » Thu Aug 25, 2016 11:01 pm

Gale,

Could you run this utility on your surface to see if it helps ?

http://error-toolkit.com/error.php?t=638
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Camera Control needed for Tablet

Postby TimStone » Mon Aug 29, 2016 9:23 pm

Antonio,

Looks like we have a start for a FWH camera control. You used a SaveToBMP( ) but actually we would benefit by saving pictures to an alternative file, ie. JPG.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Camera Control needed for Tablet

Postby Antonio Linares » Mon Aug 29, 2016 10:00 pm

Tim,

A first version

tcamera.prg
Code: Select all  Expand view
#include "FiveWin.ch"

#define GWL_STYLE -16

function Main()

   local oWnd, oCamera

   DEFINE WINDOW oWnd

   oCamera = TCamera():New( oWnd )

   oCamera:bLClicked = { || oCamera:SaveToBmp( "photo.bmp" ),;
                            WinExec( "mspaint photo.bmp" ) }

   ACTIVATE WINDOW oWnd

return nil  

CLASS TCamera FROM TControl

   CLASSDATA lRegistered AS LOGICAL

   DATA pMediaControl

   METHOD New( oWndParent, nTop, nLeft, nBottom, nRight )

ENDCLASS

METHOD New( oWndParent, nTop, nLeft, nBottom, nRight ) CLASS TCamera

   DEFAULT nTop := 15, nLeft := 15, nBottom := 300, nRight := 300

   ::pMediaControl = DShowCamera()

   ::hWnd  = FindWindow( 0, "ActiveMovie Window" )
   ::oWnd  = oWndParent
   ::nTop  = nTop
   ::nLeft = nLeft
   ::nBottom = nBottom
   ::nRight  = nRight

   SetParent( ::hWnd, ::oWnd:hWnd )
   SetWindowLong( ::hWnd, GWL_STYLE, nOr( WS_CHILD, WS_VISIBLE ) )
   SetWindowPos( ::hWnd, 0, nTop, nLeft, nBottom, nRight )

   ::Register()
   ::Link()

return Self

#pragma BEGINDUMP

#pragma warning(disable:4996)

#include <hbapi.h>
#include <dshow.h>
#include <uuids.h>
#include <objbase.h>

#import "qedit.dll" raw_interfaces_only named_guids

EXTERN_C const CLSID CLSID_NullRenderer;
EXTERN_C const CLSID CLSID_SampleGrabber;

HB_FUNC( DSHOWPLAY )
{
   IMediaControl * pMediaControl = ( IMediaControl * ) hb_parnll( 1 );

   pMediaControl->Run();
}  

HB_FUNC( DSHOWSTOP )
{
   IMediaControl * pMediaControl = ( IMediaControl * ) hb_parnll( 1 );

   pMediaControl->Stop();
}  

HB_FUNC( DSHOWCAMERA )
{
   HRESULT hr;
   ICreateDevEnum *pDevEnum = NULL;
   IEnumMoniker *pEnum = NULL;
   IMoniker *pMoniker = NULL;
   IPropertyBag *pPropBag = NULL;
   IGraphBuilder *pGraph = NULL;
   ICaptureGraphBuilder2 *pBuilder = NULL;
   IBaseFilter *pCap = NULL;
   IBaseFilter *pSampleGrabberFilter = NULL;
   IBaseFilter *pNullRenderer = NULL;
   IMediaControl *pMediaControl = NULL;
   char *pBuffer = NULL;
   VARIANT var;
    int n = 0;
    int device_number = 0;
    char device_name[ 100 ];
   char char_buffer[100];
   DexterLib::ISampleGrabber *pSampleGrabber = NULL;

   strcpy( device_name, "" );

   hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );

   if( hr != S_OK )
      MessageBox( 0, "CoInitializeEx error", "ok", 0 );

   hr = CoCreateInstance( CLSID_FilterGraph, NULL,
              CLSCTX_INPROC_SERVER, IID_IGraphBuilder,
              ( void ** ) &pGraph );
           
   if( hr != S_OK )
      MessageBox( 0, "CoCreateInstance error", "ok", 0 );
     
    hr = CoCreateInstance( CLSID_CaptureGraphBuilder2, NULL,
            CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2,
            ( void ** ) &pBuilder );      

   if( hr != S_OK )
      MessageBox( 0, "CoCreateInstance 2 error", "ok", 0 );

    hr = ( ( ICaptureGraphBuilder * ) pBuilder )->SetFiltergraph( pGraph );
   
    if( hr != S_OK )
        MessageBox( 0, "Could not attach capture graph builder to graph", "ok", 0 );
     
    hr = CoCreateInstance( CLSID_SystemDeviceEnum, NULL,
            CLSCTX_INPROC_SERVER, IID_PPV_ARGS( &pDevEnum ) );
         
    if( hr != S_OK )
        MessageBox( 0, "Could not crerate system device enumerator", "ok", 0 );
     
    hr = pDevEnum->CreateClassEnumerator(
                    CLSID_VideoInputDeviceCategory, &pEnum, 0 );
               
    if( hr != S_OK )
        MessageBox( 0, "No video devices found", "ok", 0 );      
     
    while(1)
    {
        // Access next device
        hr = pEnum->Next(1, &pMoniker, NULL);
        if( hr == S_OK )
            n++; // increment device count
      else  
         break;
       
        // If device was specified by name rather than number...
        if( device_number == 0 )
        {
            // Get video input device name
            hr = pMoniker->BindToStorage(0, 0, IID_PPV_ARGS(&pPropBag));
            if (hr == S_OK)
            {
                // Get current device name
                VariantInit(&var);
                hr = pPropBag->Read(L"FriendlyName", &var, 0);
               
                // Convert to a normal C string, i.e. char*
                sprintf(char_buffer, "%ls", var.bstrVal);
                VariantClear(&var);
                pPropBag->Release();
                pPropBag = NULL;
               
                // Exit loop if current device name matched devname
            // MessageBox( 0, char_buffer, "device_name", 0 );
           
                if (strcmp(device_name, char_buffer) == 0) break;
            }
            else
         {
                MessageBox( 0, "Error getting device names", "ok", 0 );
            break;
         }  
        }
        else if (n >= device_number) break;
    }  
   
    // Get video input device name
    hr = pMoniker->BindToStorage(0, 0, IID_PPV_ARGS(&pPropBag));
    VariantInit(&var);
    hr = pPropBag->Read(L"FriendlyName", &var, 0);
    // MessageBoxW( 0, L"Capture device", var.bstrVal, 0 );
    VariantClear(&var);  
   
    // Create capture filter and add to graph
    hr = pMoniker->BindToObject(0, 0,
                    IID_IBaseFilter, (void**)&pCap);
               
    if( hr != S_OK )
      MessageBox( 0, "Could not create capture filter", "ok", 0 );  

    // Add capture filter to graph
    hr = pGraph->AddFilter(pCap, L"Capture Filter");
   
    if( hr != S_OK )
      MessageBox( 0, "Could not add capture filter to graph", "ok", 0 );

    // Create sample grabber filter
    hr = CoCreateInstance(CLSID_SampleGrabber, NULL,
        CLSCTX_INPROC_SERVER, IID_IBaseFilter,
        (void**)&pSampleGrabberFilter);
     
    if( hr != S_OK )
        MessageBox( 0, "Could not create Sample Grabber filter", "ok", 0 );

    // Query the ISampleGrabber interface of the sample grabber filter
    hr = pSampleGrabberFilter->QueryInterface(
            DexterLib::IID_ISampleGrabber, (void**)&pSampleGrabber);
         
    if( hr != S_OK )
        MessageBox( 0, "Could not get ISampleGrabber interface to sample grabber filter", "ok", 0 );

    // Enable sample buffering in the sample grabber filter
    hr = pSampleGrabber->SetBufferSamples(TRUE);
   
    if( hr != S_OK )
        MessageBox( 0, "Could not enable sample buffering in the sample grabber", "ok", 0 );

    // Set media type in sample grabber filter
    AM_MEDIA_TYPE mt;
    ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE));
    mt.majortype = MEDIATYPE_Video;
    mt.subtype = MEDIASUBTYPE_RGB24;
    hr = pSampleGrabber->SetMediaType((DexterLib::_AMMediaType *)&mt);
   
    if( hr != S_OK )
        MessageBox( 0, "Could not set media type in sample grabber", "ok", 0 );

    // Add sample grabber filter to filter graph
    hr = pGraph->AddFilter(pSampleGrabberFilter, L"SampleGrab");
   
    if( hr != S_OK )
        MessageBox( 0, "Could not add Sample Grabber to filter graph", "ok", 0 );

    // Create Null Renderer filter
    hr = CoCreateInstance(CLSID_NullRenderer, NULL,
        CLSCTX_INPROC_SERVER, IID_IBaseFilter,
        (void**)&pNullRenderer);

   if( hr != S_OK )
        MessageBox( 0, "Could not create Null Renderer filter", "ok", 0 );

    // Add Null Renderer filter to filter graph
    hr = pGraph->AddFilter(pNullRenderer, L"NullRender");

   if( hr != S_OK )
        MessageBox( 0, "Could not add Null Renderer to filter graph", "ok", 0 );
     
   // Connect up the filter graph's capture stream
    hr = pBuilder->RenderStream(
        &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
        pCap,  pSampleGrabberFilter, pNullRenderer);
     
    if( hr != S_OK )
        MessageBox( 0, "Could not render capture video stream", "ok", 0 );

    hr = pBuilder->RenderStream(
                &PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,
                pCap, NULL, NULL);
   
   if (hr != S_OK && hr != VFW_S_NOPREVIEWPIN)
            MessageBox( 0, "Could not render preview video stream", "ok", 0 );

    // Get media control interfaces to graph builder object
    hr = pGraph->QueryInterface(IID_IMediaControl,
                    (void**)&pMediaControl);

   if( hr != S_OK )
      MessageBox( 0, "Could not get media control interface", "ok", 0 );

    // Run graph
    while(1)
    {
        hr = pMediaControl->Run();
       
        // Hopefully, the return value was S_OK or S_FALSE
        if (hr == S_OK) break; // graph is now running
        if (hr == S_FALSE) continue; // graph still preparing to run
       
        // If the Run function returned something else,
        // there must be a problem
        // fprintf(stderr, "Error: %u\n", hr);
        MessageBox( 0, "Could not run filter graph", "ok", 0 );
    }
   
   hb_retnll( ( HB_LONGLONG ) pMediaControl );
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Camera Control needed for Tablet

Postby Antonio Linares » Mon Aug 29, 2016 10:05 pm

Methods Play and Stop:

Code: Select all  Expand view
CLASS TCamera FROM TControl

   CLASSDATA lRegistered AS LOGICAL

   DATA pMediaControl

   METHOD New( oWndParent, nTop, nLeft, nBottom, nRight )

   METHOD Play() INLINE DShowPlay( ::pMediaControl )

   METHOD Stop() INLINE DShowStop( ::pMediaControl )

ENDCLASS
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Camera Control needed for Tablet

Postby HunterEC » Tue Aug 30, 2016 5:31 am

Antonio:

I tried to compile tcamera.prg using FW 16.06 and BCC7 and I got the following errors:
Code: Select all  Expand view
Error E2342 TCAMERA.prg 239: Type mismatch in parameter 'rclsid' (wanted 'const_GUID * const', got '_GUID') in function HB_FUN_DSHOWCAMERA
Error E2451 TCAMERA.prg 245: Undefined symbol 'AddFilter' in function HB_FUN_DSHOWCAMERA
Error E2451 TCAMERA.prg 251: Undefined symbol 'RenderStream' in function HB_FUN_DSHOWCAMERA
Error E2451 TCAMERA.prg 258: Undefined symbol 'RenderStream' in function HB_FUN_DSHOWCAMERA
Error E2451 TCAMERA.prg 266: Undefined symbol 'QueryInterface' in function HB_FUN_DSHOWCAMERA
Error E2451 TCAMERA.prg 275: Undefined symbol 'Run' in function HB_FUN_DSHOWCAMERA
Warning W8004 TCAMERA.prg 288: 'pBuffer' is assigned a value that is never used in function HB_FUN_DSHOWCAMERA
Warning W8004 TCAMERA.prg 288: 'pCap' is assigned a value that is never used in function HB_FUN_DSHOWCAMERA
Warning W8004 TCAMERA.prg 288: 'pPropBag' is assigned a value that is never used in function HB_FUN_DSHOWCAMERA
Warning W8004 TCAMERA.prg 288: 'pMoniker' is assigned a value that is never used in function HB_FUN_DSHOWCAMERA
Warning W8004 TCAMERA.prg 288: 'pEnum' is assigned a value that is never used in function HB_FUN_DSHOWCAMERA
Warning W8004 TCAMERA.prg 288: 'pDevEnum' is assigned a value that is never used in function HB_FUN_DSHOWCAMERA
*** 35 errors in Compile ***
* Linking errors *


What I am missing ? Thank you very much !!!
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Camera Control needed for Tablet

Postby Antonio Linares » Tue Aug 30, 2016 6:14 am

Gustavo,

It only works with Microsoft Visual Studio Community 2015
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Camera Control needed for Tablet

Postby Silvio.Falconi » Wed Jan 10, 2018 9:07 am

Can you make a version to compile with harbour bcc7 for win10pro ?
or a version with a dll or lib we can use it
i have a tablet and i need it thanks
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: Camera Control needed for Tablet

Postby Silvio.Falconi » Wed Jan 10, 2018 9:50 am

Dear Antonio

I found this http://www.rohitab.com/discuss/topic/34 ... e-class-c/

perhaps it can be usefull to use it for borland
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: Camera Control needed for Tablet

Postby TimStone » Thu Jan 11, 2018 6:38 pm

Silvio,

The application requires files only available with the Microsoft Visual Studio Community edition. It will not work with the Pelles compiler ( xHarbour xBuilder ), or Borland. The resources are not available in those programs.

The program was developed using VSC 2015 but works fine with VSC 2017 also.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 105 guests