View: 601|Reply: 6

RaspTank_pro - Camera R-B color swapped

[Copy link]

4

Threads

13

Posts

44

Credits

Newbie

Rank: 1

Credits
44
Post time 2023-12-9 02:09:12 | Show all posts |Read mode
Camera displays with swapped colors as BGR instead of RGB.  What to do?
Reply

Use magic Report

4

Threads

13

Posts

44

Credits

Newbie

Rank: 1

Credits
44
 Author| Post time 2023-12-9 05:07:47 | Show all posts
Though I may have found a solution here in FPV.py

  1. for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
Copy the Code

swap bgr for rgb.  Doesn't work.  Try again.

Reply

Use magic Report

4

Threads

13

Posts

44

Credits

Newbie

Rank: 1

Credits
44
 Author| Post time 2023-12-9 05:38:13 | Show all posts
Playing the camera with VLC via VNC desktop shows the correct colors.
Is this a problem with the webpage rather than the capture?

The VLC codec shows it is playing with YUV420, not RGB.  I can get it to do MJPEG but only to YUV420.
Switching on the auto brightness, auto gain etc. makes the image very much better.  Need to set these in the camera server code.
Reply

Use magic Report

4

Threads

13

Posts

44

Credits

Newbie

Rank: 1

Credits
44
 Author| Post time 2023-12-10 02:26:12 | Show all posts
It appears that FPV.py is not used at all for image streaming.  FPV used by wevSServer.py hereFPV_Thread only gets used by server, not webServer.
Tested by removing this linethat sends the image.

Where is the image coming from?



Reply

Use magic Report

4

Threads

13

Posts

44

Credits

Newbie

Rank: 1

Credits
44
 Author| Post time 2023-12-10 03:00:44 | Show all posts
The function by webServer is in camera_opencv hereTested putting a rgb to bgr conversion in and it worked.
I don't yet know if the problem is at frame delivery or camera capture. So I don't know where to put the conversion.

Reply

Use magic Report

4

Threads

13

Posts

44

Credits

Newbie

Rank: 1

Credits
44
 Author| Post time 2023-12-10 05:08:04 | Show all posts
Getting somewhere when changing settings in camera_opencv.py

Added camera capture settings to reduce resolution and frame rate.  That significantly improves performance of everything.
Added setting to adjust exposure an gain.  This makes the image much brighter in low light conditions.  Still experimenting with this.
Auto exposure and balance doesn't appear to work yet.



        camera.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
        camera.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
        camera.set(cv2.CAP_PROP_FPS, 10)
        camera.set(cv2.CAP_PROP_EXPOSURE, 3000)
        camera.set(cv2.CAP_PROP_GAIN, 10)   
#        camera.set(cv2.CAP_PROP_AUTO_WB, 1)
#        camera.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1)
#        camera.set(cv2.CAP_PROP_CONVERT_RGB, 1)
Reply

Use magic Report

0

Threads

1

Posts

4

Credits

Newbie

Rank: 1

Credits
4
Post time 2024-2-28 17:05:11 | Show all posts
It seems that VLC is using YUV420 rather than RGB when it plays videos.  As far as I can tell, it can only handle YUV420 MJPEG.
Auto brightness, auto gain, and other similar features greatly improve the picture quality.  These variables must be defined in the camera server program.
Reply

Use magic Report

You have to log in before you can reply Login | Sign Up

Points Rules