Skip to content

Commit

Permalink
more signed/unsigned cleanups to address compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
agalasso committed Nov 6, 2017
1 parent ab8de23 commit a0c7fb4
Show file tree
Hide file tree
Showing 27 changed files with 76 additions and 86 deletions.
2 changes: 1 addition & 1 deletion aui_controls.cpp
Expand Up @@ -573,7 +573,7 @@ SBStateIndicators::SBStateIndicators(SBPanel* panel, std::vector<int>& fldWidths

SBStateIndicators::~SBStateIndicators()
{
for (unsigned inx = 0; inx < stateItems.size(); inx++)
for (unsigned int inx = 0; inx < stateItems.size(); inx++)
delete stateItems.at(inx);
}

Expand Down
9 changes: 5 additions & 4 deletions cam_Altair.cpp
Expand Up @@ -309,14 +309,15 @@ inline static int round_up(int v, int m)
}


void __stdcall CameraCallback(unsigned nEvent, void* pCallbackCtx)
void __stdcall CameraCallback(unsigned int event, void *pCallbackCtx)
{
if (nEvent == ALTAIRCAM_EVENT_IMAGE)
if (event == ALTAIRCAM_EVENT_IMAGE)
{
Camera_Altair* pCam = (Camera_Altair*)pCallbackCtx;
Camera_Altair *pCam = (Camera_Altair *) pCallbackCtx;
pCam->FrameReady();
}
}

//static void flush_buffered_image(int cameraId, usImage& img)
//{
// enum { NUM_IMAGE_BUFFERS = 2 }; // camera has 2 internal frame buffers
Expand Down Expand Up @@ -426,7 +427,7 @@ bool Camera_Altair::Capture(int duration, usImage& img, int options, const wxRec
}
}

for (int i = 0; i < img.NPixels; i++)
for (unsigned int i = 0; i < img.NPixels; i++)
img.ImageData[i] = m_buffer[i];

if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
Expand Down
2 changes: 1 addition & 1 deletion cam_LEwebcam.cpp
Expand Up @@ -151,7 +151,7 @@ bool CameraLEWebcam::Capture(int duration, usImage& img, int options, const wxRe
// This is because we are not exactly sure when we will capture the "Long Exposure"
// frame

for(int i=0;i < frame1.NPixels; i++)
for (unsigned int i = 0;i < frame1.NPixels; i++)
{
sum1 += *dptr1++;
sum2 += *dptr2++;
Expand Down
2 changes: 1 addition & 1 deletion cam_QGuide.cpp
Expand Up @@ -190,7 +190,7 @@ bool CameraQGuider::Capture(int duration, usImage& img, int options, const wxRec
//qglogfile->AddLine("Exposure done"); //qglogfile->Write();

/* dptr = img.ImageData;
for (i=0; i<img.NPixels; i++,dptr++) {
for (unsigned int i=0; i<img.NPixels; i++,dptr++) {
*dptr = 0;
}
*/
Expand Down
6 changes: 3 additions & 3 deletions cam_SAC42.cpp
Expand Up @@ -98,7 +98,7 @@ bool CameraSAC42::Capture(int duration, usImage& img, int options, const wxRect&
unsigned char *bptr;
unsigned short *dptr;
unsigned char *buffer;
int retval, i;
int retval;
bool firstimg = true;
int chunksize = MaxExposure; // exp dur of subframes in longer exposures

Expand Down Expand Up @@ -139,13 +139,13 @@ bool CameraSAC42::Capture(int duration, usImage& img, int options, const wxRect&
dptr = img.ImageData;

if (firstimg) {
for (i = 0; i < img.NPixels; i++, dptr++, bptr++) { // bring in image from camera's buffer
for (unsigned int i = 0; i < img.NPixels; i++, dptr++, bptr++) { // bring in image from camera's buffer
*dptr = (unsigned short) *bptr;
}
firstimg = false;
}
else {
for (i = 0; i < img.NPixels; i++, dptr++, bptr++) { // add in next image
for (unsigned int i = 0; i < img.NPixels; i++, dptr++, bptr++) { // add in next image
unsigned int sum = (unsigned int) *dptr + (unsigned short) *bptr;
if (sum > 65535)
sum = 65535;
Expand Down
9 changes: 5 additions & 4 deletions cam_VFW.cpp
Expand Up @@ -123,7 +123,7 @@ bool CameraVFW::Disconnect() {

bool CameraVFW::Capture(int duration, usImage& img, int options, const wxRect& subframe)
{
int xsize,ysize, i;
int xsize, ysize;
int NFrames = 0;
xsize = FullSize.GetWidth();
ysize = FullSize.GetHeight();
Expand All @@ -148,11 +148,12 @@ bool CameraVFW::Capture(int duration, usImage& img, int options, const wxRect& s
cap_img = VFW_Window->GetwxImage();
imgdata = cap_img.GetData();
dptr = img.ImageData;
for (i=0; i<img.NPixels; i++, dptr++, imgdata+=3) {
for (unsigned int i = 0; i < img.NPixels; i++, dptr++, imgdata += 3) {
*dptr = *dptr + (unsigned short) (*imgdata + *(imgdata+1) + *(imgdata+2));
}
}
NFrames++;
if ((swatch.Time() >= duration) && (NFrames > 2)) still_going=false;
if ((swatch.Time() >= duration) && (NFrames > 2))
still_going = false;
}
pFrame->StatusMsg(wxString::Format("%d frames",NFrames));
if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
Expand Down
2 changes: 1 addition & 1 deletion cam_ZWO.cpp
Expand Up @@ -582,7 +582,7 @@ bool Camera_ZWO::Capture(int duration, usImage& img, int options, const wxRect&
}
else
{
for (int i = 0; i < img.NPixels; i++)
for (unsigned int i = 0; i < img.NPixels; i++)
img.ImageData[i] = m_buffer[i];
}

Expand Down
2 changes: 1 addition & 1 deletion cam_ascom.cpp
Expand Up @@ -312,7 +312,7 @@ static bool ASCOM_Image(IDispatch *cam, usImage& Image, bool takeSubframe, const
}
else
{
for (int i = 0; i < Image.NPixels; i++)
for (unsigned int i = 0; i < Image.NPixels; i++)
Image.ImageData[i] = (unsigned short) rawdata[i];
}

Expand Down
21 changes: 8 additions & 13 deletions cam_firewire_IC.cpp
Expand Up @@ -276,29 +276,24 @@ void CameraFirewire::InitCapture()

bool CameraFirewire::Capture(int duration, usImage& img, int options, const wxRect& subframe)
{
int xsize, ysize, i;
unsigned short *dataptr;
unsigned char *imgptr;
Error err;
bool retval;
static int programmed_dur = 200;

xsize = FullSize.GetWidth();
ysize = FullSize.GetHeight();
int xsize = FullSize.GetWidth();
int ysize = FullSize.GetHeight();

if (img.Init(FullSize))
{
pFrame->Alert(_("Memory allocation error"));
return true;
}
dataptr = img.ImageData;
unsigned short *dataptr = img.ImageData;

if ((duration != programmed_dur) && (m_pExposureAbs != 0)) {
m_pExposureAbs->setValue(duration / 1000.0);
programmed_dur = duration;
}

retval = m_pGrabber->startLive(false);
bool retval = m_pGrabber->startLive(false);
if (!retval) {
pFrame->Alert(_("Could not start video stream"));
return true;
Expand All @@ -309,7 +304,7 @@ bool CameraFirewire::Capture(int duration, usImage& img, int options, const wxRe

// grab the next frame

err = pSink->snapImages( 1,15000 );
Error err = pSink->snapImages( 1,15000 );
if (err.getVal() == eTIMEOUT_PREMATURLY_ELAPSED) {
wxMilliSleep(200);
err = pSink->snapImages( 1,15000 );
Expand All @@ -325,17 +320,17 @@ bool CameraFirewire::Capture(int duration, usImage& img, int options, const wxRe
(int) err.getVal(), (int) eTIMEOUT_PREMATURLY_ELAPSED, wxString(err.c_str())), NO_RECONNECT);
return true;
}
imgptr = (unsigned char *) pSink->getLastAcqMemBuffer()->getPtr();
unsigned char *imgptr = (unsigned char *) pSink->getLastAcqMemBuffer()->getPtr();

for (i=0; i<img.NPixels; i++, dataptr++, imgptr++)
for (unsigned int i = 0; i < img.NPixels; i++, dataptr++, imgptr++)
*dataptr = (unsigned short) *imgptr;

/* if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &vframe)!=DC1394_SUCCESS) {
DisconnectWithAlert(_("Cannot get a frame from the queue"));
return true;
}
imgptr = vpFrame->image;
for (i=0; i<img.NPixels; i++, dataptr++, imgptr++)
for (unsigned int i = 0; i < img.NPixels; i++, dataptr++, imgptr++)
*dataptr = (unsigned short) *imgptr;
dc1394_capture_enqueue(camera, vframe); // release this frame
*/
Expand Down
26 changes: 11 additions & 15 deletions cam_firewire_OSX.cpp
Expand Up @@ -254,30 +254,25 @@ bool CameraFirewire::Disconnect()

bool CameraFirewire::Capture(int duration, usImage& img, int options, const wxRect& subframe)
{
int xsize, ysize, i;
unsigned short *dataptr;
unsigned char *imgptr;
dc1394video_frame_t *vframe;
int err;
static int programmed_dur = 1000;
wxStopWatch swatch;

xsize = FullSize.GetWidth();
ysize = FullSize.GetHeight();
int xsize = FullSize.GetWidth();
int ysize = FullSize.GetHeight();

if (img.NPixels != (xsize*ysize)) {
if (img.Init(xsize,ysize)) {
if (img.NPixels != (unsigned int)(xsize * ysize)) {
if (img.Init(xsize, ysize)) {
DisconnectWithAlert(CAPT_FAIL_MEMORY);
return true;
}
}
swatch.Start();
dataptr = img.ImageData;
unsigned short *dataptr = img.ImageData;

if (DCAM_start_stop_mode) {
dc1394_video_set_transmission(camera, DC1394_ON);
dc1394switch_t status = DC1394_OFF;
for (i=0; i<5; i++) {
for (int i=0; i<5; i++) {
wxMilliSleep(10);
dc1394_video_get_transmission(camera, &status);
if (status != DC1394_OFF) break;
Expand All @@ -297,10 +292,11 @@ bool CameraFirewire::Capture(int duration, usImage& img, int options, const wxRe
programmed_dur = duration;
}

dc1394video_frame_t *vframe = nullptr;

// Flush
if (DCAM_flush_mode) {
vframe = NULL;
vframe = nullptr;
dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_POLL, &vframe);
if (vframe) dc1394_capture_enqueue(camera, vframe);
dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_POLL, &vframe);
Expand Down Expand Up @@ -354,16 +350,16 @@ bool CameraFirewire::Capture(int duration, usImage& img, int options, const wxRe
DisconnectWithAlert(_("Cannot get a frame from the queue"), NO_RECONNECT);
return true;
}
imgptr = vframe->image;
unsigned char *imgptr = vframe->image;
// pFrame->StatusMsg(wxString::Format("%d %d %d",(int) vpFrame->frames_behind, (int) vpFrame->size[0], (int) vpFrame->size[1]));
for (i=0; i<img.NPixels; i++, dataptr++, imgptr++)
for (unsigned int i = 0; i < img.NPixels; i++, dataptr++, imgptr++)
*dataptr = (unsigned short) *imgptr;
dc1394_capture_enqueue(camera, vframe); // release this frame
// pFrame->StatusMsg(wxString::Format("Behind: %lu Pos: %lu",vpFrame->frames_behind,vpFrame->id));
if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);

if (DCAM_start_stop_mode)
dc1394_video_set_transmission(camera,DC1394_OFF);
dc1394_video_set_transmission(camera, DC1394_OFF);

return false;
}
Expand Down
8 changes: 3 additions & 5 deletions cam_opencv.cpp
Expand Up @@ -123,7 +123,6 @@ bool CameraOpenCV::Capture(int duration, usImage& img, int options, const wxRect
{
wxStopWatch swatch;
Mat captured_frame;
int i, nframes;

if (!pCapDev)
{
Expand All @@ -149,16 +148,15 @@ bool CameraOpenCV::Capture(int duration, usImage& img, int options, const wxRect

img.Clear();

nframes = 0;
unsigned char *dptr;
dptr = captured_frame.data;
int nframes = 0;
unsigned char *dptr = captured_frame.data;
while (swatch.Time() < duration)
{
nframes++;
pCapDev->read(captured_frame);
cvtColor(captured_frame,captured_frame,CV_RGB2GRAY);
dptr = captured_frame.data;
for (i = 0; i < img.NPixels; i++)
for (unsigned int i = 0; i < img.NPixels; i++)
{
unsigned int t = (unsigned int) img.ImageData[i] + (unsigned int) dptr[i];
if (t > 65535)
Expand Down
5 changes: 2 additions & 3 deletions cam_simulator.cpp
Expand Up @@ -651,7 +651,7 @@ bool SimCamState::ReadNextImage(usImage& img, const wxRect& subframe)
}
else
{
for (int i = 0; i < img.NPixels; i++)
for (unsigned int i = 0; i < img.NPixels; i++)
img.ImageData[i] = (unsigned short) buf[i];
}

Expand Down Expand Up @@ -1149,7 +1149,6 @@ bool CameraSimulator::Capture(int duration, usImage& img, int options, const wxR
wxImage disk_image;
unsigned short *dataptr;
unsigned char *imgptr;
int i;

bool retval = disk_image.LoadFile("/Users/stark/dev/PHD/simimage.bmp");
if (!retval) {
Expand All @@ -1165,7 +1164,7 @@ bool CameraSimulator::Capture(int duration, usImage& img, int options, const wxR

dataptr = img.ImageData;
imgptr = disk_image.GetData();
for (i=0; i<img.NPixels; i++, dataptr++, imgptr++) {
for (unsigned int i = 0; i < img.NPixels; i++, dataptr++, imgptr++) {
*dataptr = (unsigned short) *imgptr;
imgptr++; imgptr++;
}
Expand Down
2 changes: 1 addition & 1 deletion configdialog.cpp
Expand Up @@ -183,7 +183,7 @@ int ConfigDialogCtrlSet::StringArrayWidth(const wxArrayString& ary)
{
int width = 0;

for (unsigned i = 0; i < ary.size(); i++)
for (unsigned int i = 0; i < ary.size(); i++)
{
int thisWidth = StringWidth(ary[i]);

Expand Down
8 changes: 4 additions & 4 deletions darks_dialog.cpp
Expand Up @@ -446,7 +446,7 @@ struct Histogram
{
memset(&val[0], 0, sizeof(val));
mean = 0.0;
for (int i = 0; i < img.NPixels; i++)
for (unsigned int i = 0; i < img.NPixels; i++)
{
unsigned short v = img.ImageData[i];
mean += v;
Expand All @@ -462,7 +462,7 @@ struct Histogram
for (i = 0; i < 256; i++)
{
sum += val[i];
if (sum > (unsigned)img.NPixels / 2)
if (sum > img.NPixels / 2)
break;
}
median = i << (img.BitsPerPixel - 8);
Expand Down Expand Up @@ -528,7 +528,7 @@ bool DarksDialog::CreateMasterDarkFrame(usImage& darkFrame, int expTime, int fra

unsigned int *iptr = avgimg;
const unsigned short *usptr = darkFrame.ImageData;
for (int i = 0; i < darkFrame.NPixels; i++)
for (unsigned int i = 0; i < darkFrame.NPixels; i++)
*iptr++ += *usptr++;
}

Expand All @@ -537,7 +537,7 @@ bool DarksDialog::CreateMasterDarkFrame(usImage& darkFrame, int expTime, int fra
ShowStatus(_("Dark frames complete"), true);
const unsigned int *iptr = avgimg;
unsigned short *usptr = darkFrame.ImageData;
for (int i = 0; i < darkFrame.NPixels; i++)
for (unsigned int i = 0; i < darkFrame.NPixels; i++)
*usptr++ = (unsigned short)(*iptr++ / frameCount);
}

Expand Down
2 changes: 1 addition & 1 deletion event_server.cpp
Expand Up @@ -1811,7 +1811,7 @@ static GUIDE_DIRECTION dir_param(const json_value *p)
{ "right", GUIDE_DIRECTION::RIGHT },
};

for (unsigned i = 0; i < WXSIZEOF(dirs); i++)
for (unsigned int i = 0; i < WXSIZEOF(dirs); i++)
if (wxStricmp(p->string_value, dirs[i].s) == 0)
return dirs[i].d;

Expand Down
4 changes: 2 additions & 2 deletions gear_dialog.cpp
Expand Up @@ -910,7 +910,7 @@ void GearDialog::OnButtonSelectCamera(wxCommandEvent& event)

wxMenu *menu = new wxMenu();
int id = MENU_SELECT_CAMERA_BEGIN;
for (unsigned idx = 0; idx < names.size(); idx++)
for (unsigned int idx = 0; idx < names.size(); idx++)
{
wxMenuItem *item = menu->AppendRadioItem(id, names.Item(idx));
if (idx < m_cameraIds.size())
Expand All @@ -934,7 +934,7 @@ void GearDialog::OnButtonSelectCamera(wxCommandEvent& event)

void GearDialog::OnMenuSelectCamera(wxCommandEvent& event)
{
unsigned idx = event.GetId() - MENU_SELECT_CAMERA_BEGIN;
unsigned int idx = event.GetId() - MENU_SELECT_CAMERA_BEGIN;
if (idx >= 0 && idx < m_cameraIds.size())
{
wxString key = CameraSelectionKey(m_pCamera);
Expand Down

0 comments on commit a0c7fb4

Please sign in to comment.