How to capture an image in java?

Closed
bienfaitmurhula
Posts
13
Registration date
Monday May 8, 2017
Status
Member
Last seen
September 13, 2020
- Updated on Sep 14, 2020 at 03:16 AM
sjainnahta
Posts
1
Registration date
Saturday August 21, 2021
Status
Member
Last seen
August 21, 2021
- Aug 21, 2021 at 05:07 AM
Hello,

How to capture an image in java !!
I wanted to have some clear explanations

1 reply

sjainnahta
Posts
1
Registration date
Saturday August 21, 2021
Status
Member
Last seen
August 21, 2021

Aug 21, 2021 at 05:07 AM
Java usually doesn't like accessing hardware, so you will need a driver program of some sort, as goldenmean said. I've done this on my laptop by finding a command line program that snaps a picture. Then it's the same as goldenmean explained; you run the command line program from your java program in the takepicture() routine, and the rest of your code runs the same.

Except for the part about reading pixel values into an array, you might be better served by saving the file to BMP, which is nearly that format already, then using the standard java image libraries on it.

Using a command line program adds a dependency to your program and makes it less portable, but so was the webcam, right?
0