Go to Post If this thread isn't a sign that CD is going through some serious withdrawals, I don't know what is. - Ty Tremblay [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 26-01-2013, 13:45
d.kho's Avatar
d.kho d.kho is offline
Registered User
AKA: Daniel Kho
FRC #2473 (CHSR)
Team Role: Leadership
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Cupertino
Posts: 8
d.kho is an unknown quantity at this point
Question RGBImage Issues

Has anyone else had an issue trying to create an RGBImage from a file? When using this code:
Code:
RGBImage* image = new RGBImage("testPattern.jpg")
I always got the error "RGBImage not declared". All of the includes are right, and WindRiver can give me the tooltips for the constructor when I hover my mouse over it. Trying to manually include the file led to some more errors though.

I ended up getting it to work by creating my own RGBImage using the nivision stuff though.
Reply With Quote
  #2   Spotlight this post!  
Unread 26-01-2013, 20:50
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is offline
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 157
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: RGBImage Issues

This code will be running on the robot when it runs - don't know if that's obvious or not -- and as such, 'testPattern.jpg' must be on the robot and must be in the 'current working directory' of the running program. If you're feeling confident that all this makes sense so far, I would suggest that you try doing a little test to ensure that the file is really "there" by opening the file and reading the first 4 bytes of the file or something...if the following all checks out then I'd ask ... how are you creating this testPattern.jpg file? Could it have been saved in a different format than .jpg by a writing function? I seem to recall a situation last year where files we were writing wound up being BMP format instead of JPG due to a saving issue.

Code:
FILE* fp = fopen("testPattern.jpg", "rb");
if (fp) {
  unsigned char test[10];
  int read;

  read = fread(test, 1, 4, fp);
  if (read != 4) {
    printf("Did not read 4 bytes. Error.\n");
  }
  else {
    printf("SUCCESS. File at least exists.\n");
  }
}
else {
  printf("File not found.\n");
}
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote
  #3   Spotlight this post!  
Unread 26-01-2013, 20:58
Toa Circuit's Avatar
Toa Circuit Toa Circuit is offline
Thaddeus Maximus
AKA: Thad Hughes
FRC #4213 (MetalCow Robotics)
Team Role: Leadership
 
Join Date: Nov 2012
Rookie Year: 2012
Location: Shirley, IL
Posts: 131
Toa Circuit is an unknown quantity at this point
Re: RGBImage Issues

This is a compile-time error, yes? I place this code in my compiler and it works...
Oh. You're missing a semicolon.
Try
Code:
RGBImage* image = new RGBImage("testPattern.jpg");
Instead.
__________________

2012 Head of Programming and Electrical
2013-14 Overall Team Captain and Programming Head
2012-14 Mentor of FLL Team Power Surge
2014 Dean's List Finalist
2014 CIR Xerox Creativity Award
Webpage
Reply With Quote
  #4   Spotlight this post!  
Unread 27-01-2013, 00:00
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 671
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: RGBImage Issues

Quote:
Originally Posted by bob.wolff68 View Post
If you're feeling confident that all this makes sense so far, I would suggest that you try doing a little test to ensure that the file is really "there" by opening the file and reading the first 4 bytes of the file or something...
Code:
FILE* fp = fopen("testPattern.jpg", "rb");
if (fp) {
  unsigned char test[10];
  int read;
 
  read = fread(test, 1, 4, fp);
  if (read != 4) {
    printf("Did not read 4 bytes. Error.\n");
  }
  else {
    printf("SUCCESS. File at least exists.\n");
  }
}
else {
  printf("File not found.\n");
}
BTW, if you read and display the first 16 bytes instead of the first 4 bytes, you will see a 4-byte signature at offset 6 that will tell you if the file is a JPG or not. I believe JPG files have something like "Exif" or "JFIF" at offset 6 whereas BMP files have "BM" as the first 2 bytes of the file. There may be some other valid signatures, but you get a pretty good idea on what format the file is.
__________________
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:34.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi