NetTalk Central

Author Topic: Issues displaying NetTalk camera images in a Windows application.  (Read 2619 times)

jari@softmade.fi

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • Email
I?m having trouble getting images taken with the NetTalk (image is saved to the BLOB) camera to display in my Windows application.
But if I load a file into the BLOB, everything works fine both on the web and in the Windows application .
However, images taken with the camera are visible on the web, but not in the Windows application.

Any ideas?

rjolda

  • Sr. Member
  • ****
  • Posts: 333
    • View Profile
    • Email
Re: Issues displaying NetTalk camera images in a Windows application.
« Reply #1 on: November 11, 2024, 03:11:26 AM »
HI, NT stores the pictures in the images folder under the web folder as PMG files.  NT apps should be able to save to BLOB and to the images folder. Can you access the png images in the images folder.  You should be able to view these images on your NT server with any program which will open a graphic.  If you can do this, try your windows APP. It should be able to open this as well.
I am not sure what you are really trying to say about your image in a BLOB and your windows application.  However, Web applications can open images delivered from blobs almost natively.  That does NOT exist in desktop applications.  On desktop, try using BlobToFile in String theory and save it to disk and use that image file in your web app.  You can delete the image file when procedure is done.
Maybe this will get you started.
Ron 

jari@softmade.fi

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • Email
Re: Issues displaying NetTalk camera images in a Windows application.
« Reply #2 on: November 11, 2024, 04:30:43 AM »
Hi Ron

I created a test program that demonstrates the issue. Copy it to the Webcam (79) folder.

Jari

JohanR

  • Sr. Member
  • ****
  • Posts: 376
    • View Profile
    • Email
Re: Issues displaying NetTalk camera images in a Windows application.
« Reply #3 on: November 11, 2024, 07:34:24 AM »
Hi Jari

I would try to save the image to disk to validate it and debug that way

I did have a quick look, but got a compile error when I tried to add the blobtoimage function

Will have a look later when I have more time

Johan

 

JohanR

  • Sr. Member
  • ****
  • Posts: 376
    • View Profile
    • Email
Re: Issues displaying NetTalk camera images in a Windows application.
« Reply #4 on: November 11, 2024, 09:12:45 PM »
Hi Jari

From the BLOB help
If you need to save images to a BLOB, and later restore them to an output file, the type of image should also be saved in the database (JPG, GIF, BMP, etc.).
Using BLOBTOFILE to save to a different extension can produce unpredictable results.

Possible problem is that the original file is PNG, and when the Blob is saved to disk it's a base64 encoded png file.
so you probably need to do some decoding and converting the image to different format.


regards

Johan


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11254
    • View Profile
Re: Issues displaying NetTalk camera images in a Windows application.
« Reply #5 on: November 11, 2024, 10:37:41 PM »
have you looked inside the blob record to see what is actually there? is it binary, or base64 encoded?

JohanR

  • Sr. Member
  • ****
  • Posts: 376
    • View Profile
    • Email
Re: Issues displaying NetTalk camera images in a Windows application.
« Reply #6 on: November 11, 2024, 11:34:45 PM »
Hi Bruce

Yes,

below first few chars from the file that was saved with this code in the desktop program.

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10dzkAAAAAX

Code in desktop program
loc:filename = 'c:\tmp\' & random(11111,99999) & '.jpg'
IF BLOBTOFILE(ALI:Photo,loc:filename)  !returns an ERRORCODE if copy fails
   MESSAGE('BLOB did not copy due to the following ERRORCODE: ' & ERRORCODE())
else
   tmp_st.loadfile(loc:filename)
   message('saved:') 
END
Copying that to decoding website produces an image file.

Think it needs a few more lines of code to sort it out to display on screen

regards

Johan





I

JohanR

  • Sr. Member
  • ****
  • Posts: 376
    • View Profile
    • Email
Re: Issues displaying NetTalk camera images in a Windows application.
« Reply #7 on: November 11, 2024, 11:38:07 PM »
Hi Bruce

Sorry ,
The loading of the file into a ST object was to try the ST decode,
but I had some issues with saving the file into usbale format.
will check again later and and try to figure out why

Johan

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11254
    • View Profile
Re: Issues displaying NetTalk camera images in a Windows application.
« Reply #8 on: November 14, 2024, 04:50:15 PM »
>> below first few chars from the file that was saved with this code in the desktop program.
>> data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10dzkAAAAAX

Images can be stored in blobs in multiple ways. This format is used in the web when the images are delived "inline" rather than in a separate request. To convert to binary;

a) remove the text at the start up to, and including the ,
b) base 64 decode it.

As you can see the header shows both the format of the image (png) and the base64 encoding. Should you wish, you can parse out that header to better choose the file name, and note the base64 decoding.

Cheers
Bruce

jari@softmade.fi

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • Email
Re: Issues displaying NetTalk camera images in a Windows application.
« Reply #9 on: November 14, 2024, 10:26:44 PM »
 Thank you, Bruce and other gurus.

I did it like this using FreeImage and StringTheory.

loc:text     CSTRING(600000)



    Access:Liitteet.Fetch(Liit:Ind_haku)             
   
    i#= kuva.iImage.Load(Liit:blob)
       
    if i#=0
        st.fromblob(Liit:blob)
        l#=st.instring(',')
        loc:text=st.getvalue()
        loc:text= sub(loc:text,l#+1, st.len())
        st.setvalue(loc:text)
        st.Base64Decode()
        st.toblob(Liit:blob)
       
        i#= kuva.iImage.Load(Liit:blob)
    end

JohanR

  • Sr. Member
  • ****
  • Posts: 376
    • View Profile
    • Email
Re: Issues displaying NetTalk camera images in a Windows application.
« Reply #10 on: November 15, 2024, 06:41:09 AM »


Hi Jari

Some suggestions , sure there are other ways too.

Seeing as you have it in a stringtheory object already, no reason to move to local text field, use the ST methods
Also possibly search for something a bit more specific eg.  data:image/png;base64,

I don't have enough knowledge of image formats ,encoding and you should be searching for,
but you might encounter a different image, with a different starting string, or a random comma, but it's not valid for what you need.
You can then expand on the search string, to other possibilities, if required

              tmp_st.fromblob(ALI:Photo)
              pos# = tmp_st.FindChars('data:image/png;base64,')
              if pos# = 0
                 message('not found')
              else
                 if pos# = 1
                    tmp_st.RemoveFromPosition(pos#,22)
                    tmp_st.Base64Decode()
                   
                    loc:filename = 'c:\tmp\' & random(11111,99999) & '.png'
                    tmp_st.savefile(loc:filename)
                    tmp_st.toblob(ALI:Photo)
                   
                    message('done and saved to:' & loc:filename)
                 else
                    message('possible other issue')
                 end
              end