void Trk::Init(int track_num, bool controls)
{
    prev = NULL;
    next = NULL;
    trknum = track_num;
    active = false;
    bunched = buncho = bunchito = false;
    trktype = Trk_Usual;
    start_line = track_num;
    end_line = track_num;
    trk_start_line = track_num;
    trk_end_line = track_num;
    trkbunch = NULL;
    defined_instr = NULL;
    params = new ParamSet(100, 50, &scope);
    envelopes = NULL;
    mcell = NULL;
    mchan = NULL;
    memset(&scope, 0, sizeof(Scope));
    scope.for_track = true;
    scope.trkdata = this;
    vol = NULL;
    pan = NULL;
    mute = NULL;
    solo = NULL;

    if(controls == true)
    {
        vol = new SliderHVol(59, NULL, &scope);
        pan = new SliderHPan(40, NULL, &scope);
        //pan = new Knob(6, NULL, NULL, &scope, Knob_Small);

        pan->SetHint("Track panning\0");
        vol->SetHint("Track volume\0");

    	params->vol->AddControl(vol);
        params->pan->AddControl(pan);
        params->vol->SetNormalValue(1.0f);
        params->pan->SetNormalValue(0.0f);

        vol->SetAnchor(1);
        pan->SetAnchor(0);

        mute = new Toggle(this, Toggle_Mute);
        solo = new Toggle(this, Toggle_Solo);

        mute->SetHint("Mute track\0");
        solo->SetHint("Solo track\0");

        AddNewControl(pan, NULL);
        AddNewControl(vol, NULL);
        AddNewControl(mute, NULL);
        AddNewControl(solo, NULL);
    }

    vol_lane = Lane(false, 3, Lane_Vol);
    pan_lane = Lane(false, 3, Lane_Pan);

    UpdateLaneBases();
}
Пример #2
0
 Cell_Data Location (int index, int lane, int cell)
 {
     Index (index);
     Lane (lane);
     Cell (cell);
     return (*this);
 }
Пример #3
0
Traveler_Data::Traveler_Data (int traveler, int time) : 
	Class2_Index (traveler, time), Static_Scale ()
{
	Vehicle (0);
	Link_Dir (0);
	Offset (0);
	Lane (0);
	Distance (0);
	Speed (0);
}
Пример #4
0
void
NIImporter_ITSUMO::Handler::myEndElement(int element) {
    switch (element) {
        case ITSUMO_TAG_SIMULATION: {
            for (std::vector<Section*>::iterator i = mySections.begin(); i != mySections.end(); ++i) {
                for (std::vector<LaneSet*>::iterator j = (*i)->myLaneSets.begin(); j != (*i)->myLaneSets.end(); ++j) {
                    LaneSet* ls = (*j);
                    NBEdge* edge = new NBEdge(ls->myID, ls->myFrom, ls->myTo, "", ls->myV, (unsigned int)ls->myLanes.size(), -1, NBEdge::UNSPECIFIED_WIDTH, NBEdge::UNSPECIFIED_OFFSET);
                    if (!myNetBuilder.getEdgeCont().insert(edge)) {
                        delete edge;
                        WRITE_ERROR("Could not add edge '" + ls->myID + "'. Probably declared twice.");
                    }
                    delete ls;
                }
                delete *i;
            }
        }
        break;
        case ITSUMO_TAG_NODE: {
            try {
                std::string id = myParameter["id"];
                SUMOReal x = TplConvert::_2SUMOReal(myParameter["x"].c_str());
                SUMOReal y = TplConvert::_2SUMOReal(myParameter["y"].c_str());
                Position pos(x, y);
                if (!NILoader::transformCoordinates(pos)) {
                    WRITE_ERROR("Unable to project coordinates for node '" + id + "'.");
                }
                NBNode* node = new NBNode(id, pos);
                if (!myNetBuilder.getNodeCont().insert(node)) {
                    delete node;
                    WRITE_ERROR("Could not add node '" + id + "'. Probably declared twice.");
                }
            } catch (NumberFormatException&) {
                WRITE_ERROR("Not numeric position information for node '" + myParameter["id"] + "'.");
            } catch (EmptyData&) {
                WRITE_ERROR("Missing data in node '" + myParameter["id"] + "'.");
            }
        }
        break;
        case ITSUMO_TAG_SECTION: {
            mySections.push_back(new Section(myParameter["sectionID"], myCurrentLaneSets));
            myCurrentLaneSets.clear();
        }
        break;
        case ITSUMO_TAG_LANESET: {
            try {
                std::string id = myParameter["lanesetID"];
                int i = TplConvert::_2int(myParameter["i"].c_str());
                std::string fromID = myParameter["from"];
                std::string toID = myParameter["to"];
                NBNode* from = myNetBuilder.getNodeCont().retrieve(fromID);
                NBNode* to = myNetBuilder.getNodeCont().retrieve(toID);
                if (from == 0 || to == 0) {
                    WRITE_ERROR("Missing node in laneset '" + myParameter["lanesetID"] + "'.");
                } else {
                    if (myLaneSets.find(id) != myLaneSets.end()) {
                        WRITE_ERROR("Fond laneset-id '" + id + "' twice.");
                    } else {
                        SUMOReal vSum = 0;
                        for (std::vector<Lane>::iterator j = myCurrentLanes.begin(); j != myCurrentLanes.end(); ++j) {
                            vSum += (*j).myV;
                        }
                        vSum /= (SUMOReal) myCurrentLanes.size();
                        LaneSet* ls = new LaneSet(id, myCurrentLanes, vSum, i, from, to);
                        myLaneSets[id] = ls;
                        myCurrentLaneSets.push_back(ls);
                        myCurrentLanes.clear();
                    }
                }
            } catch (NumberFormatException&) {
                WRITE_ERROR("Not numeric value in laneset '" + myParameter["lanesetID"] + "'.");
            } catch (EmptyData&) {
                WRITE_ERROR("Missing data in laneset '" + myParameter["lanesetID"] + "'.");
            }
        }
        break;
        case ITSUMO_TAG_LANE: {
            try {
                std::string id = myParameter["laneID"];
                int i = TplConvert::_2int(myParameter["i"].c_str());
                SUMOReal v = TplConvert::_2SUMOReal(myParameter["v"].c_str());
                myCurrentLanes.push_back(Lane(id, (unsigned int) i, v));
            } catch (NumberFormatException&) {
                WRITE_ERROR("Not numeric value in lane '" + myParameter["laneID"] + "'.");
            } catch (EmptyData&) {
                WRITE_ERROR("Missing data in lane '" + myParameter["laneID"] + "'.");
            }
        }
        break;
        default:
            break;
    }
}
Пример #5
0
//void processLanes(CvSeq *lines, IplImage* edges, IplImage *temp_frame)
static void processLanes(CvSeq *lines, IplImage* edges, IplImage *temp_frame, IplImage *org_frame)
{
  /* classify lines to left/right side */
  std::vector<Lane> left, right;

  for (int i=0; i<lines->total; i++)
    {
      CvPoint *line = (CvPoint *)cvGetSeqElem(lines, i);
      int dx = line[1].x - line[0].x;
      int dy = line[1].y - line[0].y;
      float angle = atan2f(dy, dx) * 180/CV_PI;

      if (fabs(angle) <= LINE_REJECT_DEGREES) // reject near horizontal lines
        {
          continue;
        }

      /* assume that vanishing point is close to the image horizontal center
         calculate line parameters: y = kx + b; */
      dx = (dx == 0) ? 1 : dx;  // prevent DIV/0!
      float k = dy/(float)dx;
      float b = line[0].y - k*line[0].x;

      /* assign lane's side based by its midpoint position */
      int midx = (line[0].x + line[1].x) / 2;
      if (midx < temp_frame->width/2)
        {
          left.push_back(Lane(line[0], line[1], angle, k, b));
        }
      else if (midx > temp_frame->width/2)
        {
          right.push_back(Lane(line[0], line[1], angle, k, b));
        }
    }

  /* show Hough lines */
  int org_offset = temp_frame->height;
  for (std::size_t i = 0; i < right.size(); ++i)
    {
      CvPoint org_p0 = right[i].p0;
      org_p0.y += org_offset;
      CvPoint org_p1 = right[i].p1;
      org_p1.y += org_offset;
#ifdef USE_POSIX_SHARED_MEMORY
#ifdef SHOW_DETAIL
      cvLine(temp_frame, right[i].p0, right[i].p1, BLUE, 2);
#endif
      cvLine(org_frame, org_p0, org_p1, BLUE, 2);
#endif
    }
  for (std::size_t i = 0; i < left.size(); ++i)
    {
      CvPoint org_p0 = left[i].p0;
      org_p0.y += org_offset;
      CvPoint org_p1 = left[i].p1;
      org_p1.y += org_offset;
#ifdef USE_POSIX_SHARED_MEMORY
#ifdef SHOW_DETAIL
      cvLine(temp_frame, left[i].p0, left[i].p1, RED, 2);
#endif
      cvLine(org_frame, org_p0, org_p1, RED, 2);
#endif
    }

  processSide(left, edges, false);
  processSide(right, edges, true);

  /* show computed lanes */
  int x = temp_frame->width * 0.55f;
  int x2 = temp_frame->width;
#if defined(USE_POSIX_SHARED_MEMORY)
#ifdef SHOW_DETAIL
  cvLine(temp_frame, cvPoint(x, laneR.k.get()*x + laneR.b.get()),
         cvPoint(x2, laneR.k.get()*x2 + laneR.b.get()), PURPLE, 2);
#endif

  cvLine(org_frame, cvPoint(x, laneR.k.get()*x + laneR.b.get() + org_offset),
         cvPoint(x2, laneR.k.get()*x2 + laneR.b.get() + org_offset), PURPLE, 2);
#else
  lane_detector::ImageLaneObjects lane_msg;
  lane_msg.lane_r_x1 = x;
  lane_msg.lane_r_y1 = laneR.k.get()*x + laneR.b.get() + org_offset;
  lane_msg.lane_r_x2 = x2;
  lane_msg.lane_r_y2 = laneR.k.get()*x2 + laneR.b.get() + org_offset;
#endif

  x = temp_frame->width * 0;
  x2 = temp_frame->width * 0.45f;
#if defined(USE_POSIX_SHARED_MEMORY)
#ifdef SHOW_DETAIL
  cvLine(temp_frame, cvPoint(x, laneL.k.get()*x + laneL.b.get()),
         cvPoint(x2, laneL.k.get()*x2 + laneL.b.get()), PURPLE, 2);
#endif

  cvLine(org_frame, cvPoint(x, laneL.k.get()*x + laneL.b.get() + org_offset),
         cvPoint(x2, laneL.k.get()*x2 + laneL.b.get() + org_offset), PURPLE, 2);
#else
  lane_msg.lane_l_x1 = x;
  lane_msg.lane_l_y1 = laneL.k.get()*x + laneL.b.get() + org_offset;
  lane_msg.lane_l_x2 = x2;
  lane_msg.lane_l_y2 = laneL.k.get()*x2 + laneL.b.get() + org_offset;

  image_lane_objects.publish(lane_msg);
#endif
  // cvLine(org_frame, cvPoint(lane_msg.lane_l_x1, lane_msg.lane_l_y1), cvPoint(lane_msg.lane_l_x2, lane_msg.lane_l_y2), RED, 5);
  // cvLine(org_frame, cvPoint(lane_msg.lane_r_x1, lane_msg.lane_r_y1), cvPoint(lane_msg.lane_r_x2, lane_msg.lane_r_y2), RED, 5);
}
Пример #6
0
	void Location (int link, int lane, int offset) 
									{ Link (link); Lane (lane); Offset (offset); }
int main(int argc, char ** argv)
{
	IplImage* image = cvLoadImage("1.png");
	IplImage* gray = cvCreateImage(cvGetSize(image), 8, 1);
	IplImage* bin = cvCreateImage(cvGetSize(image), 8, 1);
	IplImage* contourBeatle = cvCreateImage(cvGetSize(image), 8, 1);
	IplImage* contourScan = cvCreateImage(cvGetSize(image), 8, 1);
	IplImage* contourLane = cvCreateImage(cvGetSize(image), 8, 1);
	IplImage* rgbBeatle = cvCloneImage(image);
	IplImage* rgbScan = cvCloneImage(image);
	IplImage* rgbLane = cvCloneImage(image);
	
	cvCvtColor(image, gray, CV_BGR2GRAY);
	cvThreshold(gray, bin, 0, 255, CV_THRESH_OTSU);
	
	Beatle(bin, contourBeatle);
	Scan(bin, contourScan);
	Lane(bin, contourLane);

	for (int r = 0; r < image->height; ++r)
	{
		for (int c = 0; c < image->width; ++c)
		{
			if (*cvPtr2D(contourBeatle, r, c) == 0)
			{
				*cvPtr2D(rgbBeatle, r, c) = 0; // B
				*(cvPtr2D(rgbBeatle, r, c) + 1) = 0; // G
				*(cvPtr2D(rgbBeatle, r, c) + 2) = 0; // R
			}

			if (*cvPtr2D(contourScan, r, c) == 0)
			{
				*cvPtr2D(rgbScan, r, c) = 0; // B
				*(cvPtr2D(rgbScan, r, c) + 1) = 0; // G
				*(cvPtr2D(rgbScan, r, c) + 2) = 0; // R
			}

			if (*cvPtr2D(contourLane, r, c) == 0)
			{
				*cvPtr2D(rgbLane, r, c) = 0; // B
				*(cvPtr2D(rgbLane, r, c) + 1) = 0; // G
				*(cvPtr2D(rgbLane, r, c) + 2) = 0; // R
			}
		}
	}

	cvShowImage("image", image);
	cvShowImage("gray", gray);
	cvShowImage("bin", bin);
	cvShowImage("contourBeatle", contourBeatle);
	cvShowImage("contourScan", contourScan);
	cvShowImage("contourLane", contourLane);
	cvShowImage("rgbBeatle", rgbBeatle);
	cvShowImage("rgbScan", rgbScan);
	cvShowImage("rgbLane", rgbLane);
	cvSaveImage("im_contourBeatle.bmp", contourBeatle);
	cvSaveImage("im_contourScan.bmp", contourScan);
	cvSaveImage("im_contourLane.bmp", contourLane);
	cvSaveImage("im_rgbBeatle.bmp", rgbBeatle);
	cvSaveImage("im_rgbScan.bmp", rgbScan);
	cvSaveImage("im_rgbLane.bmp", rgbLane);

	while (true)
	{
		int c = cvWaitKey();
		
		if ((char)c == 27)
			break;
	}
}
Пример #8
0
 Cell_Data (int i, int l, int c) {
     Index (i);
     Lane (l);
     Cell (c);
 }