View: 861|Reply: 8

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

0

Threads

2

Posts

10

Credits

Newbie

Rank: 1

Credits
10
Post time 2024-8-26 16:03:43 | Show all posts
Try manually fine-tuning the exposure, gain, and white balance settings to optimize performance in various lighting conditions. Ensure the camera drivers are updated, and consider testing different resolutions or frame rates. For auto exposure and balance, verify compatibility with your camera and OpenCV version.

half body sexdoll
Reply

Use magic Report

0

Threads

2

Posts

6

Credits

Newbie

Rank: 1

Credits
6
Post time 2024-10-8 15:27:55 | Show all posts
The red and blue color swap on your RaspTank Pro camera is likely due to the way the image is being processed. If you're using OpenCV, it may be reading images in BGR instead of RGB format. You can correct this by converting the color space with cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) in your code. If you're using PiCamera, make sure the capture format is set to 'rgb' or check other formats like 'yuv' to see if the issue persists.

If the color swap remains, it could be a firmware or driver issue. Ensure your Raspberry Pi and camera module have the latest updates to avoid any hardware-related problems.


_______________________
https://www.medipakiet.pl/blog/w ... iedobor-dawkowanie/
Reply

Use magic Report

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

Points Rules