×

INDI Library v2.0.7 is Released (01 Apr 2024)

Bi-monthly release with minor bug fixes and improvements

OpenCV

  • Posts: 35
  • Thank you received: 1

OpenCV was created by erik

Hi,

I'm currently writing a little client in cpp to automated evaluate images and check wethere there are satellites in image. I'm using linux, the cameras are an EOS 6D and an ASI Zwoptical 120 color CMOS.
For image processing I'd like to translate the images coming with the newBlob Function of the baseclient as IBLOB structs to an cv::Mat. What the constructor of the cv::Mat needs is a pointer to the start of the image data, not sure if void* blob does that job (?), and the bytes per pixel. Last is in the CCD_INFO NumberVectorProperty, but I'm still needing the void pointer to the binary data. Can I use the pointer contained in the struct or is there f.eks. any fits header i've to consider as well?

By the way, what exatly is in the format string?

Thanks for any help! :cheer:
typedef struct {			/* one BLOB descriptor */
  /** index name */
  char name[MAXINDINAME];		
  /** this BLOB's label */
  char label[MAXINDILABEL];	
  /** format attr */	
  char format[MAXINDIBLOBFMT];	
  /** malloced binary large object bytes */
  void *blob;			
  /** bytes in blob */	
  int bloblen;			
  /** n uncompressed bytes */
  int size;				
  /** pointer to parent */
  struct _IBLOBVectorProperty *bvp;	
  /** handy place to hang helper info */
  void *aux0, *aux1, *aux2;		
} IBLOB;
7 years 2 months ago #14492

Please Log in or Create an account to join the conversation.

Replied by Jasem Mutlaq on topic OpenCV

The format is the blob file format. i.e. "fits", "jpeg", "cr2"..etc. The points is to the start of the file data in your case. You can't use openCV if it's FITS directly without using cfitsio to parse the fits data. For CR2, you might need to use dcraw/libraw as well.
The following user(s) said Thank You: erik
7 years 2 months ago #14494

Please Log in or Create an account to join the conversation.

  • Posts: 35
  • Thank you received: 1

Replied by erik on topic OpenCV

Thanks first of all. I've got another question kinda related to that, but didn't want to start a new thread.

How can I read the number of channels from the camera interface? So, I got the ASI 120 CM, which means it makes color images and it's fits must hence have three dimensions. Is there a property (INDI interface or fits IO) where I can read that from. I wasn't able to find some of that kind yet.

What I alread got is below. Still missing the automated declaration of cv_type.

Thanks in advance!
int cv_type;
      int status=0;
      int nelements=0;
      char error_status[100];
      int nullval=0;
      int anynull;
      int byte_type=0;
      void* memptr;
      fitsfile * fptr=NULL;
 
      fits_open_memfile(&fptr,&(bp->blob),&(bp->bloblen),2880,realloc,&status);
 
      if(status)
      {
	fits_report_error(stderr, status);  /* print out any error messages */
	fits_get_errstatus(status, error_status);
	DEBUGF(INDI::Logger::DBG_ERROR, "FITS Error (open_memfile): %s", error_status);
	return;
      }
 
      switch (cam_env.bits_per_pixel)
      {
	  case 8:
	      byte_type = TBYTE;
// 	      cv_type = CV_8UC3; //f.eks.
	      break;
 
	  case 16:
	      byte_type = TUSHORT;
	      break;
 
	  case 32:
	      byte_type = TULONG;
	      break;
 
	  default:
	    DEBUGF(Logger::DBG_WARNING, "Unsupported bits per pixel value %d\n", cam_env1.bits_per_pixel);
	    return;
	    break;
      }
 
      nelements = cam_env.pixel.area();
 
      fits_read_img(&fptr, byte_type, 1, nelements, &nullval, memptr, &anynull, &status);
 
      if(status)
      {
	fits_report_error(stderr, status);  /* print out any error messages */
	fits_get_errstatus(status, error_status);
	DEBUGF(INDI::Logger::DBG_ERROR, "FITS Error (read_img): %s", error_status);
	return;
      }
 
      img = cv::Mat(cam_env.pixel, cv_type, memptr);
7 years 1 month ago #14681

Please Log in or Create an account to join the conversation.

Time to create page: 0.508 seconds