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

Image noise getting worse after very first frame taken when service is up #67

Open
AyrtonRicardo opened this issue Feb 7, 2024 · 3 comments

Comments

@AyrtonRicardo
Copy link
Contributor

Very funny situation on my use case, when I use a resolution like "1920x1440", with "vr90" option, after restart spyglass and keep refreshing the snapshot endpoint till I get the very first image, the very first image is pretty good, but the second onward is VERY noisy 😭

Image 1:
image

Images after first snapshot call:
image

Do you have any idea what can be causing this?
I'm using tunning file: https://github.com/raspberrypi/libcamera/blob/main/src/ipa/rpi/pisp/data/ov5647_noir.json

@mryel00
Copy link
Owner

mryel00 commented Feb 7, 2024

with "vr90" option

Maybe I just forgot about it, but what exactly do you mean with vr90? I guess you mean -or r90?
Anyway that doesn't matter here.

The second image looks like a very low bitrate. Overall Spyglass isn't processing the images besides, adding the exif header into the binary, if you use -or. This might lead to problems showing the image as libcamera recently added exif support themselves, but this shouldn't affect anything like your second picture.
We then send that image with a simple web server on requests.
If you now see compression like that it's most likely already happening before spyglass get's the picture, as you would just receive framedrops if your network would be too slow to receive the images.

We will look into it, if you can force some bitrate with picamera2 or maybe through libcamera controls.
But as you can see on the commit history, the development is currently on a longer pause due to personal life of both of us.
The development will resume in a few weeks, when I have more time again for everything.

It would be good, if you could provide following informations:

  • The Pi you are using
  • All your settings
  • The exact model of camera you are using
  • A picture of the front of the camera PCB
  • If you are using some custom code modifications or maybe another branch besides the main branch

Some other note about something I saw on that second picture, is the green line at the bottom (left). I saw already similar problems with camera-streamer, where you see that line primarily with WebRTC iirc. So there might be something up with the HW encoders of the Pis.

Another thing, that I didn't test yet much myself is using "non-default" resolutions, especially for those 4:3 sensors like the OV5647 and IMX219 (picam v1 and v2 respectively). libcamera-hello --list-cameras gives you four resolutions for the OV5647 sensor. None of those is 1920x1440. That might lead to cropping or other things. I will do some testing about that in future with my v2 cam, too.

So for now I leave this issue open until we have done more testing on the things I mentioned.

@AyrtonRicardo
Copy link
Contributor Author

@mryel00 thanks for replying so quickly, I came here looking for help, this is almost sure not be related to spyglass but I thought that maybe something I could pass to libcamera as a parameter would help :D

I'm in the middle of a print right now to test, but I tried to keep common ration while adding the resolution, but the result was the same as you see with the odd resolution.

My goal is to use the fov as wide as I can for the camera in vertical position as "squared" as possible.

  • Camera: https://www.amazon.de/-/en/gp/product/B095NQT3GJ
    • Very generic picam using ov5647 chip.
  • Settings below.
  • RPI 3 Model B 1GB
  • I can't take a pic right now, but I think the amazon images are good enough?
  • No custom code, I just pushed my changes here and since accepted I'm running main branch.
  • autofocus also didn't made any changes.
$ libcamera-hello --list-cameras
Available cameras
-----------------
0 : ov5647 [2592x1944] (/base/soc/i2c0mux/i2c@1/ov5647@36)
    Modes: 'SGBRG10_CSI2P' : 640x480 [30.00 fps - (0, 0)/0x0 crop]
                             1296x972 [30.00 fps - (0, 0)/0x0 crop]
                             1920x1080 [30.00 fps - (0, 0)/0x0 crop]
                             2592x1944 [30.00 fps - (0, 0)/0x0 crop]

Settings:

NO_PROXY="true"
HTTP_PORT="8080"
RESOLUTION="1600x1280"
FPS="15"
STREAM_URL="/stream"
SNAPSHOT_URL="/snapshot"
AUTO_FOCUS="manual"
FOCAL_DIST="0.0"
AF_SPEED="normal"
ORIENTATION_EXIF="r90"
TUNING_FILTER="ov5647_noir.json"

Currently running 1280x1600:
image
Which seems a little better, but it still way too much noise comparing to the first time the snapshot is made.(can't restart spyglass right now)

My camera position:
image

@mryel00
Copy link
Owner

mryel00 commented Feb 7, 2024

The picture isn't needed anymore. I just wanted to check if it's an original v1, a fake v1 or maybe some other OV5647 sensor cam.

It's ofc completely fine to reach out for some advice from us, but I still have to always make sure that everyone reading something like this, knows that it's not something Spyglass is doing, but something on a lower level.
I learned that while supporting for crowsnest, as a lot of people draw wrong conclusions on some things, as they simply lack the knowledge in that field.

autofocus also didn't made any changes.

OV5647 sensors don't have autofocus afaik. We just added that option as a start parameter, because Spyglass was mostly intended for the v3 as it wasn't supported by crowsnest at that time.

As the compression artifacts get better with lowering the resolution (1296x972), it might be due to not enough processing power that it starts compressing the image to get the specified fps. Try to lower resolution or fps further down and see if it gets better.

Because you are using a Pi3B, I will also do some testing on that device, when I get time for it. I mostly used Spyglass on a Pi4.

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