ArduCAM / MIPI_Camera

232 stars 108 forks source link

Green frame during video capture #179

Open sandeep1404 opened 1 year ago

sandeep1404 commented 1 year ago

Hi Everyone,

I have IMX230 camera sensor with me and I was trying to integrate it with Jetson nano and capture the photos, I followed the documentation https://docs.arducam.com/Nvidia-Jetson-Camera/Jetvariety-Camera/Quick-Start-Guide/ in setting the camera, however I was getting a green frame when I run the code python arducam_displayer.py.

Also when I run my code for a simple capturing images it still ended up giving me green frames, My opencv has gstremer as backend My code is mentioned below:

import cv2

import imutils # pip install imutils

import numpy as np
from datetime import datetime
import array
import fcntl
import os
import argparse
from utils import ArducamUtils
import sys
from pip import main as pipmain

camera = True
if camera == True:
    cap = cv2.VideoCapture(0,cv2.CAP_V4L2) #cv2.CAP_V4L2
    arducam_utils = ArducamUtils(0)
    w = cap.set(cv2.CAP_PROP_FRAME_WIDTH,640)
    h = cap.set(cv2.CAP_PROP_FRAME_HEIGHT,480)
    #frame = frame.reshape(int(h), int(w))
    print(arducam_utils)

else:
    vid = cv2.VideoCapture('E:\arducam\mycam.mp4')

if arducam_utils.convert2rgb == 0:
    cap.set(cv2.CAP_PROP_CONVERT_RGB,arducam_utils.convert2rgb )#arducam_utils.convert2rgb

if camera:
    i=0
    while (cap.isOpened()):
        try:
            print('cam opened')     
            img, frame = cap.read()         
            frame=arducam_utils.convert(frame)
            frame = imutils.resize(frame,width=640)
            cv2.imshow('frame', frame)
            cv2.imwrite(f"/home/jetson/Desktop/cam_test/Client_Frame12_{i}.jpg", frame)
            i=i+1

        except:
            print('VIDEO FINISHED!')
            break

Client_Frame12_0

My output image from the camera is as shown in the figure, why is the green frame is coming I tried many color conversions but not able to get a good color image, and gstreamer also gives me internal data stream error always. can anyone please help me in resolving the issues asap its very urgent and any solution will be greatly helpful from me. Thankyou in advance.

sandeep1404 commented 1 year ago

Can someone help me in resolving this issue, it very urgent