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

IMX264 sensor not accepting colors correctly. #116

Open
hseysen opened this issue Aug 21, 2024 · 1 comment
Open

IMX264 sensor not accepting colors correctly. #116

hseysen opened this issue Aug 21, 2024 · 1 comment

Comments

@hseysen
Copy link

hseysen commented Aug 21, 2024

I'm using NVIDIA Jetson Nano with L4T 32.7.4 and IMX264 camera sensor. I have configured the .dtsi file and I can successfully obtain an image using nvarguscamerasrc using GStreamer, and also argus_camera using the jetson_multimedia_api. However, I visually see that the camera does not recognize the colors correctly.

I've tried to write a Python script using OpenCV, and here is the code:

import cv2

cap = cv2.VideoCapture("/dev/video0", cv2.CAP_V4L)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 2432)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 2048)
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('R', 'G', 'G', 'B'))
cap.set(cv2.CAP_PROP_CONVERT_RGB, 0)

if not cap.isOpened():
	print("Error: Failed to open camera.")
	exit(1)

image_id = 0
while True:
	ret, frame = cap.read()
	print(frame.shape)
	print(frame.dtype)
	frame = frame.reshape((2048, 2432))
	if not ret:
		print("Error: Failed to grab frame.")
		continue
	frame = cv2.cvtColor(frame, cv2.COLOR_BAYER_RG2RGB)

	frame_resized = cv2.resize(frame, (608, 512))
	cv2.imshow("Frame", frame_resized)
	
	key = cv2.waitKey(1) & 0xFF
	if key == ord('q'):
		break
	elif key == ord('c'):
		cv2.imwrite(f"capture{image_id}.png", frame)
		print(f"Image captured as: capture{image_id}.png")
		image_id += 1

cap.release()
cv2.destroyAllWindows()

Here is the image I put up on my phone's screen: https://m.media-amazon.com/images/I/71Icb3wd6DL.jpg
Here is the image captured: https://imgur.com/loQ30Bh

The script gives me a rather darker image, the nvarguscamerasrc pipelines give me a brighter view. Maybe I'm missing something on the OpenCV script.

@hseysen
Copy link
Author

hseysen commented Aug 22, 2024

I also have an IMX566 camera sensor available to me, for which I just changed the .dtsi settings for, and can confirm that it can distinguish colors correctly. This might be something related to the IMX264 sensor? Or perhaps that is the intended behavior, some kind of limitation on the perceived colors?

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

1 participant