Author Topic: Camera  (Read 24115 times)

Zarhan

  • Sr. Member
  • ****
  • Posts: 287
    • View Profile
Camera
« Reply #45 on: February 25, 2020, 06:43:53 am »
Quote from: guizmox
I'm not telling the pictures are bad, but you can safely choose a 6mpx resolution when taking pictures with the Cosmo

Problem is that there is no 6 Mpix resolution available.

5632x4224 is the "native".

Close to 6 Mpix are
3264x2448 (8 Mpix)
2560x1920 (5 Mpix)

So I'm a bit concerned about using either of these in case there will be some interpolation and therefore fuzzying of detail that will happen. Or is there some way to set a custom resolution?

guizmox

  • Newbie
  • *
  • Posts: 7
    • View Profile
Camera
« Reply #46 on: February 25, 2020, 06:38:26 am »
I'll try with the default camera app (provided by Mediatek), it could possibly bypass pixel-binding in good lighning conditions.

guizmox

  • Newbie
  • *
  • Posts: 7
    • View Profile
Camera
« Reply #47 on: February 25, 2020, 07:51:03 am »
Quote from: Zarhan
Quote from: guizmox
I'm not telling the pictures are bad, but you can safely choose a 6mpx resolution when taking pictures with the Cosmo

Problem is that there is no 6 Mpix resolution available.

5632x4224 is the "native".

Close to 6 Mpix are
3264x2448 (8 Mpix)
2560x1920 (5 Mpix)

So I'm a bit concerned about using either of these in case there will be some interpolation and therefore fuzzying of detail that will happen. Or is there some way to set a custom resolution?

I would go for the 5mpx setting, the 8mpx would fit better with a 32mpx sensor.

Zarhan

  • Sr. Member
  • ****
  • Posts: 287
    • View Profile
Camera
« Reply #48 on: February 25, 2020, 09:30:33 am »
Quote from: guizmox
I would go for the 5mpx setting, the 8mpx would fit better with a 32mpx sensor.

Yeah, but it's not exactly correct.

I'm thinking that the best way forward here might be to keep camera shooting at 24 mpix, with JPEG quality to maximum, and then just do this in Termux:

Code: [Select]
mogrify -quality 95 -resize \>2816 ~/storage/dcim/OpenCamera/*.jpg
Essentially, after shooting pics, just scan through all the files in camera directory, if they are larger than 2816 px in width, resize and also reduce jpeg compression level to lower value.

I'm not sure if this works for portrait pictures (is the rotation angle part of the EXIF data or directly part of the image). Have to test.
« Last Edit: February 25, 2020, 09:30:46 am by Zarhan »

Zarhan

  • Sr. Member
  • ****
  • Posts: 287
    • View Profile
Camera
« Reply #49 on: February 26, 2020, 12:36:17 pm »
Tested the idea just now. I seem to be getting pretty good results.

In OpenCamera, set image settings to jpg, quality 100, max resolution.

In termux, install imagemagick, and create script "resizepics", with content as above. I added "-verbose" switch so I can actually see what it's doing. You can edit the -quality value to your liking.  The mogrify scans images and checks if image size is greater than 2816 px in width. If yes, it resizes it back to 6 mpix. The problem: This does not work for portrait images, as unlike most cameras the file is actually saved as portrait instead of saved as landscape and orientation stored in EXIF tag. I guess you can either check the orientation manually or lock orientation to landscape in Opencamera settings...but then you have to orientate manually later.

End result is that I can get perfect quality images without too much extra space consumption or valueless pixels.
« Last Edit: February 26, 2020, 12:49:41 pm by Zarhan »

Daniel W

  • Sr. Member
  • ****
  • Posts: 315
    • View Profile
Camera
« Reply #50 on: February 27, 2020, 07:30:08 pm »
Another tool might be Photo Editor by dev.macgyver which has a batch tool that, among other things, can resize images. The free version does show ads, but they were quite discreet as I remember them. Been using the paid version for most of my mobile post-processing for the last couple of phones.

Daniel W

  • Sr. Member
  • ****
  • Posts: 315
    • View Profile
Camera
« Reply #51 on: March 04, 2020, 08:14:43 pm »
In this post in the thread Cosmo lower half teardown procedure, there's a link to a FCC PDF with pictures of the internals of a (Japanese, it seems) Cosmo. In a few of the pictures, the flex cable for the main camera module is visible. It's marked A24S09B F1840. Searching for the first number yields hits on Alibaba on a Sunny-Meiying "24mp camera module A24S09A PDAF" with a Samsung S5K2X7 sensor. Well, we kind of knew that, but this might conclusively prove exactly which camera module we're dealing with.

Some random data:
Origin: Zhejiang, China
Sensor: CMOS
Chip: S5K2X7SP03
Special Features: Waterproof / Weatherproof
EFL: 3.96
F.NO: 1.7±3%
Lens size: 1/2.8 inch
Array size: 5664*4256
View angle: 77.5±3°
Focusing range: 8cm-infinity
Image quality:   Center?2400LW/PH,  Corner?1600LW/PH
« Last Edit: July 28, 2020, 06:32:55 am by Varti »

Vistaus

  • Full Member
  • ***
  • Posts: 139
    • View Profile
Camera
« Reply #52 on: March 05, 2020, 05:10:07 am »
Quote from: Daniel W
Some random data:
Origin: Zhejiang, China
Sensor: CMOS
Chip: S5K2X7SP03
Special Features: Waterproof / Weatherproof
EFL: 3.96
F.NO: 1.7±3%
Lens size: 1/2.8 inch
Array size: 5664*4256
View angle: 77.5±3°
Focusing range: 8cm-infinity
Image quality:   Center?2400LW/PH,  Corner?1600LW/PH

Great find!
« Last Edit: July 28, 2020, 06:33:10 am by Varti »

maki.jouni

  • Full Member
  • ***
  • Posts: 100
    • View Profile
Camera
« Reply #53 on: March 05, 2020, 02:45:34 pm »
Quote from: Daniel W
there's a link to a FCC PDF
Little bit off topic, but there is also punch of other documents on Cosmo related FCC site.
Cosmo Communicator (Fin/Swe), Mix2, Sony Xperia XZ & Z3, Nokia N900, Nokia PARSA, HTC Touch Pro, Qtek 9100, Nokia 6600 & 6210 & 2110, Mobira Talkman

shuntcap

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Camera
« Reply #54 on: March 05, 2020, 11:58:21 pm »
Quote from: guizmox
Yes, I confirm the pixel-binding mode. It's surely driver-coded.
Correct, the binning is hard-coded in the kernel driver.  I spent quite a bit of time playing with the driver a couple of weeks ago, modifying this and that, and testing the changes under a recompiled kernel. I was unable to improve the 6 MP effective resolution limit.  The camera module setup is all done with "magic number" register writes.  They are not commented.  I believe there is likely a way to disable binning, but finding out how would require access to a confidential hardware reference manual for the chip (Samsung S5K2X7).

The driver file is drivers/misc/mediatek/imgsensor/src/common/v1_1/s5k2x7_mipi_raw/s5k2x7mipiraw_Sensor.c.

I did find a commented register write elsewhere in the MTK image sensor drivers that noted "binning_mode (0: disable, 1: enable)" for an S5K5E8 chip, but writing to the same register in the S5K2X7 driver had no effect whatsoever on the binning.

Sorry to be the bearer of bad news, everyone.

NormMonkey

  • Full Member
  • ***
  • Posts: 110
    • View Profile
Camera
« Reply #55 on: March 06, 2020, 12:51:17 pm »
I don't suppose while you were looking around at the driver, you noticed anything about enabling RAW mode?

Might not help with the binning issue, but the pictures I've gotten always seem quite processed and fairly low quality (what I would equate to "quality=75" when using ImageMagick), regardless of how high I set the quality parameters in the app.  RAW mode would at least help with that.

Has anyone tested if the camera still does its binning shenanigans if the available light is very high?

drpeter

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • http://
Camera
« Reply #56 on: March 06, 2020, 08:31:59 pm »
Quote from: shuntcap
Correct, the binning is hard-coded in the kernel driver.

This would seem to be a major bug in the Mediatek driver, admittedly one which Planet could not have anticipated.

Supposedly, the point of the Samsung technology in these sensors is to bin pixels only in situations of low light, but the driver appears to bin pixels regardless of the level of illumination.  I can confirm that this does happen even when shooting in very good light levels.

As noted elsewhere, the images also appear over-processed, as if there has been an excessive application of noise reduction.

Overall it seems as though the driver is permanently fixed in a mode heavily optimised for 'low light' photography.

None of this matters too much for low-res viewing of a full image on a 'phone screen, where these issues are not visible, but they do cause problems when cropping to a small area of the image ('digital zoom') or viewing on a large hi-resolution screen.  Under these circumstances, for outdoor scenic photography in good light the results are awful when compared side-by-side to my battered 5 year-old 16MP Galaxy Note 4.

I find it hard to believe this is anything other than a driver problem, rather than a hardware problem with the sensor.
« Last Edit: March 06, 2020, 08:34:36 pm by drpeter »

shuntcap

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Camera
« Reply #57 on: March 06, 2020, 10:27:42 pm »
Quote from: NormMonkey
I don't suppose while you were looking around at the driver, you noticed anything about enabling RAW mode?

Has anyone tested if the camera still does its binning shenanigans if the available light is very high?
Sorry, I did not find any RAW settings in the driver. That was definitely something I was looking for. I also tested the camera in bright light (and made sure the ISO was low); 5MP and 24MP images of identical scenes had no noticeable difference in detail when viewed at 100% on a large monitor.

shuntcap

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Re: Camera
« Reply #58 on: August 28, 2020, 08:20:55 am »
I found a way to save RAW .dng images on the Cosmo!  And they are beautiful!  Highly detailed, low noise, sharp as a tack across the frame, full of color, and with a great deal of shadow boosting potential.  They're a far cry from the muddy, washed out trash that the MediaTek codecs produce through the stock app and 3rd party apps like OpenCamera.  But I tried a couple dozen ports of GCam and inadvertantly found one that successfully saved RAW images.  Specifically, I installed F1MinimalMod2.1.apk, here: https://f.celsoazevedo.com/file/cfiles/gcm1/F1MinimalMod2.1.apk

See for yourself.  Here is a random sample image I took yesterday evening, first with the stock image app, then with GCam saving in RAW.  I used RawTherapee to view the .dng and slightly decreased the black level, increased the contrast and saturation a tad, and boosted the shadows a little.  In other words, I barely touched the RAW image.

Stock camera app:
 


RAW:
 


100% crop from stock:
 


Same 100% crop from RAW. Note the HUGE jump in detail and color:
 


Another 100% crop from stock.  Gloomy sky and muddy black trees:
 


Same 100% crop from RAW.  Blue, partly cloudy sky, and detailed green trees:
 


Yet another 100% crop from stock, barely recognizable flowers and blotchy grass:
 


And the same 100% crop from RAW; ah, yes, colorful flowers and detailed grass texture:
 


Those of you who are paying close attention will notice that the out-of-camera crops from the stock app are larger in physical size (click or download them).  I chose the default "24MP" resolution option for them.  But as we have already established earlier in this thread, this is only a 6MP sensor.  Now that I have RAW images, I have proof that is is ONLY A 6MP SENSOR.  In fact, this GCam port saved the actual image in literally 1/4 of the full image, the rest being black.  So why is it advertised as 24MP?  It's INTERPOLATED, upscaled to 24MP for marketing purposes.  In other words, it's a lie... sort of.  It has only 6MP of pixel detail, but being a so-called tetracell sensor from Samsung, it has four times as much light detail.  That means it works very well in low light with very little noise; that is, if you can save RAW images.  And since it is only a 6MP sensor, we can't record 4K video.

But despite being only 6MP in resolution, the RAW images are incredibly detailed with excellent color.  They matched or exceeded the detail level from the 12MP RAW images I took with a Galaxy S9 (standard sensor, not tetracell), but with much less noise.  In other words, folks, this is a fantastic little 6MP sensor from Samsung that MediaTek has utterly destroyed!

Now some of you are wondering about other camera apps like OpenCamera.  Garbage.  Forget it.  OpenCamera is great on other phones, but it produces the same toilet-quality images on the Cosmo as the stock camera app thanks to the underlying closed-source MediaTek libraries.  And for whatever reason, it can't save RAW images (produces a zero-length file).  At this point I don't know why the F1MinimalMod2.1 GCam port is able to save RAW while other apps can't, but I will surely find out in time if someone doesn't beat me to it.  I may even port GCam to the Cosmo.  After all, Planet Computers promised a "fantastic camera" (their own words on the Indiegogo story page).  They have not delivered!  But the Cosmo's camera sensor is indeed capable of delivering fantastic images!  Planet Computers, are you reading this?  Seriously, MediaTek, what were you thinking?  How can you knowingly butcher such fantastic image quality and assume no one will notice?

So what about the JPEG images from GCam?  They have the same high detail level as RAW (far greater than stock JPEG), but they're overexposed and mostly useless.  You have to process the RAW .dng image instead, at least until I or someone else finds out why this GCam port in particular can save RAW but other apps can't.  And video on the Cosmo is still awful: you'll get the same blotchy, poorly colored image quality as from stock JPEG output.  I didn't find a GCam port that could record video.

As for lighting conditions, yes, it was late evening when I took those samples above.  But even in strong sunlight, the difference in image quality between stock and RAW is equally striking.  It's like comparing a 2006-era flip phone's camera with a modern DSLR.  I strongly encourage all of you to try this out!
« Last Edit: August 28, 2020, 09:10:51 am by shuntcap »

shuntcap

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Re: Camera
« Reply #59 on: August 28, 2020, 09:00:36 am »
More samples, this time in bright morning sunlight, stock JPEG versus RAW.

Stock JPEG, scaled:
 


Same scene in RAW, scaled:
 


At first glance, the stock JPEG doesn't look half bad scaled down.  But the colors are inaccurate.  The RAW image shows the true colors.  And when we look at 100% crops, the details pop out in the RAW.

Stock JPEG, 100% crop, with blotchy trees and grayish mountains and sky:
 


Same 100% crop from RAW, with sharp tree detail and correct colors:
 


Stock JPEG, 100% crop, blotchy grass and gravel road, no shadow detail:
 


Same 100% crop from RAW, detailed grass and gravel, with visible shadow detail:
 


Stock JPEG, 100% crop, more blotchy trees and ruined color:
 


Same 100% crop from RAW, great detail and accurate color: