fbvideoclass (Windows 32/64-bit)

For issues with communication ports, protocols, etc.
D.J.Peters
Posts: 7169
Joined: May 28, 2005 3:28
Location: Germany

fbvideoclass (Windows 32/64-bit)

Postby D.J.Peters » Jan 11, 2017 10:19

For my 3d printer/scanner project I need simple video capturing in FreeBASIC so I rewrote my old fbvideocam stuff.

download: fbvideoclass.zip

Only tested on Windows 32-bit
(1 PCIE TV-card 1 USB videograbber and 2 highquality cameras and 3 simple USB web cams)

Does it works on your windows 64-bit ? (I don't know)

Joshy
Last edited by D.J.Peters on Sep 25, 2017 21:20, edited 2 times in total.
BasicCoder2
Posts: 2894
Joined: Jan 01, 2009 7:03
Location: Australia

Re: fbvideoclass (windows)

Postby BasicCoder2 » Jan 11, 2017 12:02

Sorry can't check the Window 64-bit.
However using the laptop webcam (faster than any usb plug in cam) test01 and test02 give normal still images whereas test03 and test06 produce moving images of subject matter but consist of vertical lines and with green and pink colors.
I think I had this problem when you first posted your fbvideoclass.
The escapi.bi works ok.

How are you going to use web cam images with your 3D printer? I imagined an object being scanned by a laser while rotated to extract its shape.
Or maybe its shadow outline as it is rotated.
.
MrSwiss
Posts: 2024
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: fbvideoclass (windows)

Postby MrSwiss » Jan 11, 2017 12:49

D.J.Peters wrote:Does it works on your windows 64-bit ? (I don't know)
No, not working on FBC x64, due to 32bit ASM, in ConvertRGB ().
Tested: test01.bas -- WIN 10, pro x64 / FBC 1.05.0 (64bit).
test01.asm: Assembler messages:
test01.asm:2358: Error: incorrect register `ebx' used with `q' suffix
test01.asm:2361: Error: incorrect register `edi' used with `q' suffix
test01.asm:2370: Error: operand type mismatch for `push'
test01.asm:2403: Error: operand type mismatch for `pop'
D.J.Peters
Posts: 7169
Joined: May 28, 2005 3:28
Location: Germany

Re: fbvideoclass (windows)

Postby D.J.Peters » Jan 14, 2017 17:28

test it again please

added: #if __FB_64BIT__ and one more YUY2 format

Joshy
BasicCoder2
Posts: 2894
Joined: Jan 01, 2009 7:03
Location: Australia

Re: fbvideoclass (windows)

Postby BasicCoder2 » Jan 14, 2017 18:22

It now works with the web cam integrated with the laptop.
Now can we capture multiple images as we can using the escapi.bi and easily process the images ?
.
D.J.Peters
Posts: 7169
Joined: May 28, 2005 3:28
Location: Germany

Re: fbvideoclass (windows)

Postby D.J.Peters » Jan 14, 2017 18:37

All my 5 cams works perfect on Windows 32-bit and Linux 32-bit
but I get only the half FPS rates with Linux 64-bit and Windows 64-bit !

I can use 3 or more cameras at once here on Linux but not on Windows

Joshy

MDN wrote:Remarks
Connecting a capture driver to a capture window automatically disconnects any previously connected capture driver.
Last edited by D.J.Peters on Jan 15, 2017 13:39, edited 1 time in total.
BasicCoder2
Posts: 2894
Joined: Jan 01, 2009 7:03
Location: Australia

Re: fbvideoclass (Windows 32/64-bit)

Postby BasicCoder2 » Jan 14, 2017 18:53

Do the cams have to be plugged in? WIth only the integrated camera the software stops as it can't find the other cams whereas with the escapi version the software returns the number of cams and can displays each one in its own frame. The code below saves an image when the space bar is pressed.

Code: Select all

#include "escapi.bi"


Const iWIDTH = 320
Const iHEIGHT = 240

ScreenRes 640,480,32

Dim As Integer nDevices=setupESCAPI()

If nDevices<1 Then
    Print "No active capture device found!"
    Beep:Sleep:End
Else
    if nDevices > 4 then
        nDevices = 4
    end if   
    print "number of devices=";nDevices
End If

'list of pointers
Dim shared As Any Ptr lpImage(4)

for k as integer = 0 to nDevices-1
    lpImage(k)=ImageCreate(iWIDTH,iHEIGHT)
next k

Dim Shared As SimpleCapParams Params(4)

for k as integer = 0 to nDevices-1
  Params(k).mWidth  = iWIDTH
  Params(k).mHeight = iHEIGHT
  Params(k).mTargetBuf=cptr(Integer Ptr,lpImage(k))
  Params(k).mTargetBuf+=8
  doCapture(k)
next k

for k as integer = 0 to nDevices-1
    initCapture(k, @Params(k))
next k

dim as string key,fileName
dim as integer count
'main loop
dim as integer x,y
do
    for k as integer = 0 to nDevices-1
        doCapture(k)
        locate 1,1
        While isCaptureDone(k)<>1:Sleep(10):Wend
        if k = 0 or k = 2 then x = 0 else x = 320
        if k = 0 or k = 1 then y = 0 else y = 240
        Put (x,y),lpImage(k),Pset
    next k
    key = inkey
    if key=" " then
        fileName = "c:\FreeBasic\image"+str(count)+".bmp"
        bsave fileName,0
        count = count + 1
    end if
   
loop until multikey(&H01)


for k as integer = 0 to nDevices-1
    imageDestroy(lpImage(k))
next k

End


.
MrSwiss
Posts: 2024
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: fbvideoclass (Windows 32/64-bit)

Postby MrSwiss » Jan 14, 2017 20:03

OK, fbvideoclass is now working on x64.

in "fbvideoclass.bi" two necessary changes made (before testing):

Code: Select all

Declare Sub GetStatus         (Byref s As CAPSTATUS)
Declare Sub GetParams         (Byref p As CAPTUREPARMS)
Declare Sub SetParams         (ByRef p As CAPTUREPARMS)  ' was ByVal
Declare Sub GetVideoFormat    (Byref v As BITMAPINFO)
Declare Sub SetVideoFormat    (ByRef v As BITMAPINFO)  ' was ByVal
' also in the implementations at:
' line # ca. 500 - 520
tests: ...01, 02, 03 are OK -- 04 NOK (blows at times) -- 05 and 06 are OK
D.J.Peters
Posts: 7169
Joined: May 28, 2005 3:28
Location: Germany

Re: fbvideoclass (Windows 32/64-bit)

Postby D.J.Peters » Jan 15, 2017 6:27

Thank you for the testing.

@BasicCoder2 you know ?

fbvideoclass supports WDM (windows driver model) video capture controller drivers only.

escapi (easy simple capture API) supports DS (direct show) driver devices also.

some cameras, tv-cards or video grabbers comes with both a WDM and DS driver.

All my cams and TV cards are supported by Windows XP and the linux kernel drivers V4L2 (Video for Linux version 2)

but on my Windows 10 (64-bit) I don't get a working driver for older devices:

SN9C103 web cam with microphone

AIPTEK DV3300 camcorder.

...

Joshy
MrSwiss
Posts: 2024
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: fbvideoclass (Windows 32/64-bit)

Postby MrSwiss » Jan 15, 2017 9:30

@Joshy,

you've been talking about "slowdown" on x64. Maybe all those Integers (I'd try Long).
I'm thinking about the CPU's cache, which is now mostly filled with useless ZERO's.

Just an idea ...
D.J.Peters
Posts: 7169
Joined: May 28, 2005 3:28
Location: Germany

Re: fbvideoclass (Windows 32/64-bit)

Postby D.J.Peters » Jan 15, 2017 10:13

First step of my 3D printer/scaner thing :-)

I added a tiny USB camera and two cheap line lasers provisional via a hair rubber band to the 3D printer.

click to enlarge:
Image

Before I added a single cross laser but with two line lasers
I can enable and/or disable the vertical or horizontal lines separately.
(via FreeBASIC and the LPT port)

click to enlarge:
Image

The trick are I use a low resolution of 320x240 or 160x120 pixels for the video capturing.
The point are in this rough grid of pixels the laser lines are only one pixel height/width

This are one of the small captured frame click to enlarge:
Image
and with the stepper motors I can move the camera and lasers in fine steps of 0.01 mm in all 3 axis.
(via FreeBASIC and G-CODE over serial USB port)

Next step I have to replace the provisional rubber band with a well designed holder
for the camera and lasers and print it out via the 3D printer.

Joshy

In real the lines are really thin but my fotocamera does not like the laser light and the image are out of focus = blurry.

click to enlarge:
Image
Last edited by D.J.Peters on Sep 25, 2017 21:22, edited 1 time in total.
BasicCoder2
Posts: 2894
Joined: Jan 01, 2009 7:03
Location: Australia

Re: fbvideoclass (Windows 32/64-bit)

Postby BasicCoder2 » Jan 15, 2017 21:13

At first I thought perhaps you were going to write a program to stitch together many images taken as the item is rotated to create a cloud of points.
It seems to me that home 3D printers are really only at the same stage as the first computer kits.
They need to handle many different materials and in the case of plastic items be able to mix plastics of different colors.
The ultimate 3D printer would lay down actual atoms or molecules of whatever type is required.
.
grindstone
Posts: 347
Joined: May 05, 2015 5:35
Location: Germany

Re: fbvideoclass (Windows 32/64-bit)

Postby grindstone » Jan 16, 2017 9:39

D.J.Peters wrote:In real the lines are really thin but my fotocamera does not like the laser light and the image are out of focus = blurry.
The laser light seems to be too intense. Maybe it could help to put an aperture (~ 0.3 - 0.5 mm diameter) between the laser diode and the diffusing lens to make the laser beam darker (and thinner).

Return to “Hardware Interfaces / Communication”

Who is online

Users browsing this forum: No registered users and 1 guest