Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to retrieve snapPicture jpeg even on following the exact recommended steps #3

Open
swapnill93 opened this issue May 15, 2020 · 2 comments

Comments

@swapnill93
Copy link

swapnill93 commented May 15, 2020

                              `Foscam camera = new Foscam(ip.add.here, 88, username, password);
                                System.out.println("CHECKING.." + camera.getName());
				String ret = camera.snapPicture();
				FileOutputStream fout = new FileOutputStream("testfoscam.jpg");
				byte[] rawBytes = ret.getBytes();
				
				fout.write( rawBytes , 0, rawBytes.length );
				fout.close();`

............................................................................................................................................................
OUTPUT>
CHECKING..FI9800P
............................................................................................................................................................
The output shows name of the camera . But the file foscam.jpg "can not be opened" since its damaged.
Also, I tried retrieving the picture as bufferedImage but it came out as null. The ImageIO can not decipher the bytes!


Maven:

foscamlib-mvn-repo https://raw.github.com/hypothermic/foscamapi/mvn-repo/ nl.hypothermic foscamlib 1.08-RELEASE

There is something wrong with the snapPicture() bytes
Q)

  1. How to convert snapPicture() to a viewable BufferedImage in the application itself.

  2. Is there any way to access the live video itself?

Thanks! Please help. Have been stuck on this since 2 days

@hypothermic
Copy link
Owner

  1. You would have to use some sort of JPEG parser. This functionality is not included in the library. This library is merely a HTTP wrapper around the API and only returns unparsed/raw JPEG.
  2. You can use GStreamer or OpenCV to access the stream over RTSP, here's an example: https://github.com/hypothermic/FoscamViewer (it's quite an old project and isn't supported anymore but I think it's a good example).

Possible duplicate of #2 .

@swapnill93
Copy link
Author

  1. You would have to use some sort of JPEG parser. This functionality is not included in the library. This library is merely a HTTP wrapper around the API and only returns unparsed/raw JPEG.
  2. You can use GStreamer or OpenCV to access the stream over RTSP, here's an example: https://github.com/hypothermic/FoscamViewer (it's quite an old project and isn't supported anymore but I think it's a good example).

Possible duplicate of #2 .

Thanks for the time.
I will go through the examples you have provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants